liiight/notifiers

SMTP should reconnect when disconnected

zeitderforschung opened this issue · 0 comments

Is your feature request related to a problem? Please describe.

After a while, the SMTP connection in the (g)mail provider is disconnected for some reason (network interrupted, etc). Any log message after that will no longer be transmitted by email.

Describe the solution you'd like

Log everything regardless of the connection status.

Describe alternatives you've considered

This is my workaround, do something similar. BTW you can easily simulate a disconnection with handler.provider.smtp_server.quit().

 if self.smtp_server and not callable(self.smtp_server):
      try:
          # send dummy request
          self.smtp_server.noop()
      except SMTPServerDisconnected:
          # force reconnect if disconnected
          self.smtp_server = None

Additional context

None.