use with ... for smtp
This commit is contained in:
parent
d80ecfb068
commit
c14a7b4f7a
|
@ -1297,8 +1297,14 @@ def sl_sendmail(
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# to avoid creating SMTP server every time
|
if POSTFIX_SUBMISSION_TLS:
|
||||||
smtp = get_smtp_server()
|
smtp_port = 587
|
||||||
|
else:
|
||||||
|
smtp_port = POSTFIX_PORT
|
||||||
|
|
||||||
|
with SMTP(POSTFIX_SERVER, smtp_port) as smtp:
|
||||||
|
if POSTFIX_SUBMISSION_TLS:
|
||||||
|
smtp.starttls()
|
||||||
|
|
||||||
# smtp.send_message has UnicodeEncodeError
|
# smtp.send_message has UnicodeEncodeError
|
||||||
# encode message raw directly instead
|
# encode message raw directly instead
|
||||||
|
|
Loading…
Reference in a new issue