You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to get if the pyramid_mailer is correctly configured (connection with the SMTP server is possible with given credentials).
I know I could do that by sending an email to a wrong mailbox, but I would like to avoid doing that if possible.
Is it possible to add a ping() method to the mailer that would answer true or false depending of is the connection was successful or not?
The text was updated successfully, but these errors were encountered:
def ping(self):
connection = self.smtp_factory()
# send EHLO
code, response = connection.ehlo()
if code < 200 or code >= 300:
code, response = connection.helo()
if code < 200 or code >= 300:
raise RuntimeError(
'Error sending HELO to the SMTP server '
'(code=%s, response=%s)' % (code, response))
# encryption support
have_tls = connection.has_extn('starttls')
if not have_tls and self.force_tls:
raise RuntimeError('TLS is not available but TLS is required')
if have_tls and HAVE_SSL and not self.no_tls:
connection.starttls()
connection.ehlo()
if connection.does_esmtp:
if self.username is not None and self.password is not None:
connection.login(self.username, self.password)
elif self.username:
raise RuntimeError(
'Mailhost does not support ESMTP but a username '
'is configured')
# Do not send a message
try:
connection.quit()
except SSLError:
# something weird happened while quiting
connection.close()
Every other mailer (than SMTP related ones) should return True.
Is there a way to get if the pyramid_mailer is correctly configured (connection with the SMTP server is possible with given credentials).
I know I could do that by sending an email to a wrong mailbox, but I would like to avoid doing that if possible.
Is it possible to add a ping() method to the mailer that would answer true or false depending of is the connection was successful or not?
The text was updated successfully, but these errors were encountered: