mirror of
https://github.com/simple-login/app.git
synced 2024-11-10 09:13:45 +08:00
SMTPServerDisconnected can also happen when creating SMTP server object
This commit is contained in:
parent
0b83835065
commit
1c22e14f68
1 changed files with 8 additions and 8 deletions
|
@ -1667,15 +1667,15 @@ def sl_sendmail(
|
|||
from_addr, to_addr, msg: Message, mail_options, rcpt_options, can_retry=True
|
||||
):
|
||||
"""replace smtp.sendmail"""
|
||||
if POSTFIX_SUBMISSION_TLS:
|
||||
smtp = SMTP(POSTFIX_SERVER, 587)
|
||||
smtp.starttls()
|
||||
else:
|
||||
smtp = SMTP(POSTFIX_SERVER, POSTFIX_PORT or 25)
|
||||
|
||||
# smtp.send_message has UnicodeEncodeError
|
||||
# encode message raw directly instead
|
||||
try:
|
||||
if POSTFIX_SUBMISSION_TLS:
|
||||
smtp = SMTP(POSTFIX_SERVER, 587)
|
||||
smtp.starttls()
|
||||
else:
|
||||
smtp = SMTP(POSTFIX_SERVER, POSTFIX_PORT or 25)
|
||||
|
||||
# smtp.send_message has UnicodeEncodeError
|
||||
# encode message raw directly instead
|
||||
smtp.sendmail(
|
||||
from_addr,
|
||||
to_addr,
|
||||
|
|
Loading…
Reference in a new issue