Skip to content

[Feature Request] Retry after certain exception #40

@Lee-W

Description

@Lee-W

Description

Sometimes mail service might block us from doing so much sent. Thus, if mail_handler can retry after this kind of exception would be really handle

Possible Solution

  1. catch certain types of exception
  2. sleep for a short period
  3. recover from the previous status

Additional context

Traceback (most recent call last):
  File ".../.local/bin/send_mail", line 8, in <module>
    sys.exit(main())
  File ".../.local/pipx/venvs/pycontw-mail-handler/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File ".../.local/pipx/venvs/pycontw-mail-handler/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File ".../.local/pipx/venvs/pycontw-mail-handler/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File ".../.local/pipx/venvs/pycontw-mail-handler/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File ".../.local/pipx/venvs/pycontw-mail-handler/lib/python3.8/site-packages/mail_handler/send_mail.py", line 168, in main
    send_mail(mail, user, password)
  File ".../.local/pipx/venvs/pycontw-mail-handler/lib/python3.8/site-packages/mail_handler/send_mail.py", line 92, in send_mail
    server.login(user, password)
  File ".../.pyenv/versions/3.8.5/lib/python3.8/smtplib.py", line 723, in login
    (code, resp) = self.auth(
  File ".../.pyenv/versions/3.8.5/lib/python3.8/smtplib.py", line 635, in auth
    (code, resp) = self.docmd("AUTH", mechanism + " " + response)
  File ".../.pyenv/versions/3.8.5/lib/python3.8/smtplib.py", line 425, in docmd
    return self.getreply()
  File ".../.pyenv/versions/3.8.5/lib/python3.8/smtplib.py", line 398, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed

Related Issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions