added smtp auth to cron.py

This commit is contained in:
muppeth 2022-04-20 13:01:58 +02:00
parent ea0e012c04
commit 86b725349f
Signed by: muppeth
GPG Key ID: 0EBC7B9848D04031
2 changed files with 16 additions and 0 deletions

View File

@ -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")

View File

@ -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