Compare commits
57 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 174f702e3e | |||
| 9cf25e37ed | |||
| 0c8db13341 | |||
| e5575398a3 | |||
| b31f99aa94 | |||
| c5baa2d9ab | |||
| 3aecf2eb08 | |||
| 4c28c17088 | |||
| f376656937 | |||
| a5cca5f23e | |||
| e454fd2343 | |||
| 8a175ee357 | |||
| 6626840fa9 | |||
| d1c3e68d6d | |||
| d816733b0d | |||
| 168ae345d6 | |||
| d071458032 | |||
| 7102af7d2d | |||
| 495cc43246 | |||
| 360493e564 | |||
| faac300903 | |||
| a6d7a8c8e0 | |||
| 2f94bf20be | |||
| ee1107c976 | |||
| b4c8ffe95d | |||
| 86e6a2acc1 | |||
| 432409b3d8 | |||
| fca75a30aa | |||
| 6e342ca021 | |||
| d89619fe61 | |||
| b0387362b5 | |||
| c284c1a784 | |||
| a7dd676a76 | |||
| dd4134f2d7 | |||
| c1398284c7 | |||
| a9b4fd95c3 | |||
| 0fe7aa189c | |||
| 9133bfd8fa | |||
| aa1657bd10 | |||
| 10411dd714 | |||
| 4be3686d2b | |||
| 70e1fa2a10 | |||
| 3a14430cd5 | |||
| 73621de710 | |||
| 5cbae093e9 | |||
| fdaa18c0e6 | |||
| ff6ee93497 | |||
| d62261066f | |||
| 2a852cbb51 | |||
| f561c32526 | |||
| cd36747b5c | |||
| d020bdf9d0 | |||
| cd323ab66c | |||
| 0ac236d2ff | |||
| 769a42ec8b | |||
| 60ff29b23f | |||
| 15ff3d37fc |
@@ -203,6 +203,8 @@ def mailing_subscribe_ajax(request):
|
|||||||
|
|
||||||
|
|
||||||
def send_message_ajax(request):
|
def send_message_ajax(request):
|
||||||
|
print('send_message_ajax')
|
||||||
|
|
||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
@@ -311,14 +313,18 @@ def send_message_ajax(request):
|
|||||||
f'</p>'
|
f'</p>'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print('render html for mail')
|
||||||
|
|
||||||
html = render_to_string('mail/m_request_offer.html', Dict, request)
|
html = render_to_string('mail/m_request_offer.html', Dict, request)
|
||||||
from BaseModels.mailSender import admin_send_mail_by_SMTPlib
|
from BaseModels.mailSender import admin_send_mail_by_SMTPlib
|
||||||
mail_sets = get_mail_send_options()
|
mail_sets = get_mail_send_options()
|
||||||
opts = get_options_by_opt_types('support_email', only_vals=True)
|
opts = get_options_by_opt_types('support_email', only_vals=True)
|
||||||
|
print(f'options: {str(opts)}')
|
||||||
if opts and 'support_email' in opts:
|
if opts and 'support_email' in opts:
|
||||||
to = [opts['support_email']]
|
to = [opts['support_email']]
|
||||||
else:
|
else:
|
||||||
to = [mail_sets['sender_email']]
|
to = [mail_sets['sender_email']]
|
||||||
|
print(f'to: {str(to)}')
|
||||||
res = admin_send_mail_by_SMTPlib(
|
res = admin_send_mail_by_SMTPlib(
|
||||||
mail_sets,
|
mail_sets,
|
||||||
subject=subject,
|
subject=subject,
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ def admin_send_mail_by_SMTPlib(sets, subject, from_email, to, html_content, atta
|
|||||||
|
|
||||||
def send_mail_by_SMTPlib(sets, subject, from_email, to_init, html_content, smtp_server, smtp_port, smtp_login, smtp_password,
|
def send_mail_by_SMTPlib(sets, subject, from_email, to_init, html_content, smtp_server, smtp_port, smtp_login, smtp_password,
|
||||||
attachments=None):
|
attachments=None):
|
||||||
|
print('send_mail_by_SMTPlib')
|
||||||
to = to_init
|
to = to_init
|
||||||
# if not settings.prod_server:
|
# if not settings.prod_server:
|
||||||
# to = 'web@syncsystems.net'
|
# to = 'web@syncsystems.net'
|
||||||
@@ -123,7 +124,11 @@ def send_mail_by_SMTPlib(sets, subject, from_email, to_init, html_content, smtp_
|
|||||||
try:
|
try:
|
||||||
# context = ssl.create_default_context()
|
# context = ssl.create_default_context()
|
||||||
|
|
||||||
mail_lib = smtplib.SMTP(smtp_server, smtp_port)
|
print(f'connect to mail server smtp_server={str(smtp_server)} smtp_port={str(smtp_port)}')
|
||||||
|
|
||||||
|
mail_lib = smtplib.SMTP(smtp_server, smtp_port, timeout=60)
|
||||||
|
|
||||||
|
print('connection established')
|
||||||
|
|
||||||
res = mail_lib.ehlo()
|
res = mail_lib.ehlo()
|
||||||
|
|
||||||
@@ -139,9 +144,13 @@ def send_mail_by_SMTPlib(sets, subject, from_email, to_init, html_content, smtp_
|
|||||||
res = mail_lib.esmtp_features['auth'] = 'LOGIN PLAIN'
|
res = mail_lib.esmtp_features['auth'] = 'LOGIN PLAIN'
|
||||||
# print('mail_lib.esmtp_features = {0}'.format(str(res)))
|
# print('mail_lib.esmtp_features = {0}'.format(str(res)))
|
||||||
|
|
||||||
|
print('try to login')
|
||||||
|
|
||||||
res = mail_lib.login(smtp_login, smtp_password)
|
res = mail_lib.login(smtp_login, smtp_password)
|
||||||
# print('mail_lib.login = {0}'.format(str(res)))
|
# print('mail_lib.login = {0}'.format(str(res)))
|
||||||
|
|
||||||
|
print('login')
|
||||||
|
|
||||||
res = None
|
res = None
|
||||||
|
|
||||||
if type(to) in (list, tuple):
|
if type(to) in (list, tuple):
|
||||||
@@ -159,6 +168,8 @@ def send_mail_by_SMTPlib(sets, subject, from_email, to_init, html_content, smtp_
|
|||||||
to = []
|
to = []
|
||||||
to.append(to_str)
|
to.append(to_str)
|
||||||
|
|
||||||
|
print(f'send mail to {str(to)}')
|
||||||
|
|
||||||
if type(subject) != str:
|
if type(subject) != str:
|
||||||
try:
|
try:
|
||||||
subject = subject.decode('utf-8')
|
subject = subject.decode('utf-8')
|
||||||
@@ -168,6 +179,8 @@ def send_mail_by_SMTPlib(sets, subject, from_email, to_init, html_content, smtp_
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
print(f'add context')
|
||||||
|
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
from email.headerregistry import Address
|
from email.headerregistry import Address
|
||||||
msg['From'] = from_email
|
msg['From'] = from_email
|
||||||
@@ -192,13 +205,17 @@ def send_mail_by_SMTPlib(sets, subject, from_email, to_init, html_content, smtp_
|
|||||||
res = msg.attach(attachments)
|
res = msg.attach(attachments)
|
||||||
# print('else attach file complete = {0}'.format(str(res)))
|
# print('else attach file complete = {0}'.format(str(res)))
|
||||||
|
|
||||||
|
print(f'send mail')
|
||||||
|
|
||||||
res = mail_lib.sendmail(from_email, to, msg.as_string())
|
res = mail_lib.sendmail(from_email, to, msg.as_string())
|
||||||
|
|
||||||
msg = mail_lib.quit()
|
msg = mail_lib.quit()
|
||||||
# print('mail_lib.quit = {0}'.format(str(msg)))
|
# print('mail_lib.quit = {0}'.format(str(msg)))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = 'send_mail_by_SMTPlib error = {0}'.format(str(e))
|
import traceback
|
||||||
|
msg = (f'send_mail_by_SMTPlib error = {str(e)}\n<br>'
|
||||||
|
f'{str(traceback.format_exc())}')
|
||||||
print(msg)
|
print(msg)
|
||||||
try:
|
try:
|
||||||
mail_lib.quit()
|
mail_lib.quit()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
User-agent: *
|
User-agent: *
|
||||||
Disallow: /
|
Allow: /
|
||||||
Disallow: */admin/*
|
Disallow: */admin/*
|
||||||
|
|
||||||
Host: dev.tripwb.com
|
Host: tripwb.com
|
||||||
Reference in New Issue
Block a user