Skip to content

Commit

Permalink
Merge pull request #98 from NASA-AMMOS/issue-97
Browse files Browse the repository at this point in the history
Issue #97: add configurable subject and from address
  • Loading branch information
MJJoyce committed Jul 2, 2018
2 parents 661f198 + 29f9399 commit 0053064
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ait/core/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,20 @@ def _send_email(message, recipients):
log.error('Email SMTP connection parameter error. Please check config.')
return

subject = ait.config.get('notifications.smtp.subject', 'AIT Notification')

# From address must have a valid @server, otherwise texts will not works
fromaddr = ait.config.get('notifications.smtp.from', 'ait-notify@%s' % server)

msg = MIMEText(message)
msg['Subject'] = 'AIT Notification'
msg['Subject'] = subject
msg['To'] = ', '.join(recipients)
msg['From'] = un
msg['From'] = fromaddr

try:
s = smtplib.SMTP_SSL(server, port)
s.login(un, pw)
s.sendmail(un, recipients, msg.as_string())
s.sendmail(fromaddr, recipients, msg.as_string())
s.quit()
log.info('Email notification sent')
except smtplib.SMTPException as e:
Expand Down

0 comments on commit 0053064

Please sign in to comment.