mirror of
https://github.com/simple-login/app.git
synced 2025-02-25 08:13:16 +08:00
sl_sendmail tries by default 2 times before giving up: replace can_retry by retries
This commit is contained in:
parent
2cf1c4143a
commit
24a392818b
1 changed files with 5 additions and 6 deletions
|
@ -306,7 +306,7 @@ def send_email(
|
||||||
TRANSACTIONAL_BOUNCE_EMAIL.format(transaction.id),
|
TRANSACTIONAL_BOUNCE_EMAIL.format(transaction.id),
|
||||||
to_email,
|
to_email,
|
||||||
msg,
|
msg,
|
||||||
can_retry=False,
|
retries=0, # no retry
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1269,7 +1269,7 @@ def sl_sendmail(
|
||||||
mail_options=(),
|
mail_options=(),
|
||||||
rcpt_options=(),
|
rcpt_options=(),
|
||||||
is_forward: bool = False,
|
is_forward: bool = False,
|
||||||
can_retry=True,
|
retries=2,
|
||||||
):
|
):
|
||||||
"""replace smtp.sendmail"""
|
"""replace smtp.sendmail"""
|
||||||
if NOT_SEND_EMAIL:
|
if NOT_SEND_EMAIL:
|
||||||
|
@ -1309,13 +1309,13 @@ def sl_sendmail(
|
||||||
rcpt_options,
|
rcpt_options,
|
||||||
)
|
)
|
||||||
except (SMTPServerDisconnected, SMTPRecipientsRefused) as e:
|
except (SMTPServerDisconnected, SMTPRecipientsRefused) as e:
|
||||||
if can_retry:
|
if retries > 0:
|
||||||
LOG.w(
|
LOG.w(
|
||||||
"SMTPServerDisconnected or SMTPRecipientsRefused error %s, retry",
|
"SMTPServerDisconnected or SMTPRecipientsRefused error %s, retry",
|
||||||
e,
|
e,
|
||||||
exc_info=True,
|
exc_info=True,
|
||||||
)
|
)
|
||||||
time.sleep(0.3)
|
time.sleep(0.3 * retries)
|
||||||
sl_sendmail(
|
sl_sendmail(
|
||||||
from_addr,
|
from_addr,
|
||||||
to_addr,
|
to_addr,
|
||||||
|
@ -1323,10 +1323,9 @@ def sl_sendmail(
|
||||||
mail_options,
|
mail_options,
|
||||||
rcpt_options,
|
rcpt_options,
|
||||||
is_forward,
|
is_forward,
|
||||||
can_retry=False,
|
retries=retries - 1,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
LOG.w("sendmail fails after retry")
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue