use with ... for smtp
This commit is contained in:
parent
d80ecfb068
commit
c14a7b4f7a
|
@ -1297,8 +1297,14 @@ def sl_sendmail(
|
|||
return
|
||||
|
||||
try:
|
||||
# to avoid creating SMTP server every time
|
||||
smtp = get_smtp_server()
|
||||
if POSTFIX_SUBMISSION_TLS:
|
||||
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
|
||||
# encode message raw directly instead
|
||||
|
|
Loading…
Reference in New Issue