diff --git a/gpg-mailgate-web/cron.py b/gpg-mailgate-web/cron.py index e4eeae4..4214a02 100644 --- a/gpg-mailgate-web/cron.py +++ b/gpg-mailgate-web/cron.py @@ -57,6 +57,13 @@ def send_msg( mailsubject, messagefile, recipients = None ): if 'relay' in cfg and 'host' in cfg['relay'] and 'enc_port' in cfg['relay']: relay = (cfg['relay']['host'], int(cfg['relay']['enc_port'])) smtp = smtplib.SMTP(relay[0], relay[1]) + if 'smtp' in cfg and 'enabled' in cfg['smtp'] and cfg['smtp']['enabled'] == 'true': + smtp.connect(cfg['smtp']['host'],cfg['smtp']['port']) + smtp.ehlo() + if cfg['smtp']['startls'] == 'true': + smtp.starttls() + smtp.ehlo() + smtp.login(cfg['smtp']['username'], cfg['smtp']['password']) smtp.sendmail( cfg['cron']['notification_email'], recipients, msg.as_string() ) else: appendLog("Could not send mail due to wrong configuration") diff --git a/gpg-mailgate.conf.sample b/gpg-mailgate.conf.sample index 0b74a55..8b37423 100644 --- a/gpg-mailgate.conf.sample +++ b/gpg-mailgate.conf.sample @@ -83,6 +83,15 @@ enc_port = 25 # Set this option to yes to use TLS for SMTP Servers which require TLS. starttls = no +[smtp] +# Options when smtp auth is required to send out emails +enabled = false +username = gpg-mailgate +password = changeme +host = yourdomain.tld +port = 587 +starttls = true + [database] # uncomment the settings below if you want # to read keys from a gpg-mailgate-web database