Make the SMTP relay used by cron configurable via config. Use the same as the gateway does.

This commit is contained in:
fkrone 2015-03-28 19:41:40 +01:00
parent efe2187bb5
commit d3bbb82072
1 changed files with 6 additions and 3 deletions

View File

@ -48,9 +48,12 @@ def send_msg( mailsubject, messagefile, recipients = None ):
msg.attach(MIMEText(mailbody, 'plain'))
msg.attach(MIMEText(markdown.markdown(mailbody), 'html'))
relay = ("127.0.0.1", 10028)
smtp = smtplib.SMTP(relay[0], relay[1])
smtp.sendmail( cfg['cron']['notification_email'], recipients, msg.as_string() )
if 'relay' in cfg and 'host' in cfg['relay'] and 'port' in cfg['relay']:
relay = (cfg['relay']['host'], int(cfg['relay']['port']))
smtp = smtplib.SMTP(relay[0], relay[1])
smtp.sendmail( cfg['cron']['notification_email'], recipients, msg.as_string() )
else:
appendLog("Could not send mail due to wrong configuration")
# Read configuration from /etc/gpg-mailgate.conf
_cfg = RawConfigParser()