|
|
@ -22,6 +22,8 @@ class Email(Notification): |
|
|
|
smtp_server = self.conf('smtp_server') |
|
|
|
smtp_user = self.conf('smtp_user') |
|
|
|
smtp_pass = self.conf('smtp_pass') |
|
|
|
smtp_port = self.conf('smtp_port') |
|
|
|
starttls = self.conf('starttls') |
|
|
|
|
|
|
|
# Make the basic message |
|
|
|
message = MIMEText(toUnicode(message), _charset = Env.get('encoding')) |
|
|
@ -31,9 +33,17 @@ class Email(Notification): |
|
|
|
|
|
|
|
try: |
|
|
|
# Open the SMTP connection, via SSL if requested |
|
|
|
log.debug("Connecting to host %s on port %s" % (smtp_host, smtp_port)) |
|
|
|
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) |
|
|
|
|
|
|
|
if (starttls): |
|
|
|
log.debug("Using StartTLS to initiate the connection with the SMTP server") |
|
|
|
mailserver.starttls() |
|
|
|
|
|
|
|
# Say hello to the server |
|
|
|
mailserver.ehlo() |
|
|
|
|
|
|
|
# Check too see if an login attempt should be attempted |
|
|
|
if len(smtp_user) > 0: |
|
|
|
log.debug("Logging on to SMTP server using username \'%s\'%s", (smtp_user, " and a password" if len(smtp_pass) > 0 else "")) |
|
|
|