Improve debugging for email notifications
This commit is contained in:
1 parent
2a451c255e
commit
35a9739ec5
1 file changed
+6
-1
@@ -29,18 +29,23 @@ class Email(Notification):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Open the SMTP connection, via SSL if requested
|
# Open the SMTP connection, via SSL if requested
|
||||||
|
log.debug("SMTP over SSL %s", ("enabled" if ssl == 1 else "disabled"))
|
||||||
mailserver = smtplib.SMTP_SSL(smtp_server) if ssl == 1 else smtplib.SMTP(smtp_server)
|
mailserver = smtplib.SMTP_SSL(smtp_server) if ssl == 1 else smtplib.SMTP(smtp_server)
|
||||||
|
|
||||||
# Check too see if an login attempt should be attempted
|
# Check too see if an login attempt should be attempted
|
||||||
if len(smtp_user) > 0:
|
if len(smtp_user) > 0:
|
||||||
|
log.debug("Loggin in on SMTP server using username \'%s\'%s", (smtp_user, " and password" if len(smtp_pass) > 0 else ""))
|
||||||
mailserver.login(smtp_user, smtp_pass)
|
mailserver.login(smtp_user, smtp_pass)
|
||||||
|
|
||||||
# Send the e-mail
|
# Send the e-mail
|
||||||
|
log.debug("Sending the email")
|
||||||
mailserver.sendmail(from_address, to_address, message.as_string())
|
mailserver.sendmail(from_address, to_address, message.as_string())
|
||||||
|
|
||||||
# Close the SMTP connection
|
# Close the SMTP connection
|
||||||
mailserver.quit()
|
mailserver.quit()
|
||||||
log.info('Email notifications sent.')
|
|
||||||
|
log.info('Email notification sent')
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
log.error('E-mail failed: %s', traceback.format_exc())
|
log.error('E-mail failed: %s', traceback.format_exc())
|
||||||
|
|||||||
Reference in new issue
Block a user