This commit is contained in:
rootzoll 2020-06-29 21:35:18 +02:00
commit db83cbe6c4
2 changed files with 17 additions and 11 deletions

View file

@ -93,6 +93,7 @@ def mail(recipient=None, message=None, subject=None, cert=None, encrypt=False,
print("send mail")
print("msg: {}".format(message))
print("to: {}".format(recipient))
print("from: {} <{}>".format(from_name, from_address))
print("subject: {}".format(subject))
print("cert: {}".format(cert))
print("encrypt: {}".format(encrypt))
@ -103,10 +104,10 @@ def mail(recipient=None, message=None, subject=None, cert=None, encrypt=False,
msg_content = [
"To: {}".format(recipient),
'From: "{} <{}>'.format(from_name, from_address),
'From: {} <{}>'.format(from_name, from_address),
"Subject: {}".format(subject),
"",
"{}".format(message)
"{}".format(message.encode('utf8'))
]
with open(cert, 'rb') as pem:
@ -118,10 +119,10 @@ def mail(recipient=None, message=None, subject=None, cert=None, encrypt=False,
msg = EmailMessage()
msg['Subject'] = "{}".format(subject)
msg['From'] = '"{} <{}>'.format(from_name, from_address),
msg['From'] = '{} <{}>'.format(from_name, from_address),
msg['To'] = recipient
msg.set_payload(message)
msg.set_payload(message.encode('utf8'))
msg_to_send = msg.as_bytes()
# send message via e-Mail

View file

@ -33,7 +33,11 @@ if ! grep -Eq "^notifyMailTo=.*" /mnt/hdd/raspiblitz.conf; then
fi
if ! grep -Eq "^notifyMailServer=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailServer=mail@example.com" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null
echo "notifyMailServer=mail.example.com" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null
fi
if ! grep -Eq "^notifyMailHostname=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailHostname=$(hostname)" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null
fi
if ! grep -Eq "^notifyMailUser=.*" /mnt/hdd/raspiblitz.conf; then
@ -81,16 +85,17 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=${notifyMailTo}
Root=${notifyMailTo}
# hostname of this system
hostname=${hostname}
Hostname=${notifyMailHostname}
# relay/smarthost server settings
mailhub=${notifyMailServer}
Mailhub=${notifyMailServer}
AuthUser=${notifyMailUser}
AuthPass=${notifyMailPass}
UseSTARTTLS=YES
FromLineOverride=YES
EOF
# edit raspi blitz config
@ -134,14 +139,14 @@ if [ "$1" = "send" ]; then
/home/admin/python3-env-lnd/bin/python3 /home/admin/XXsendNotification.py ext ${notifyExtCmd} "$2"
elif [ "${notifyMethod}" = "mail" ]; then
if [ "${notifyMailEncrypt}" = "on" ]; then
/home/admin/python3-env-lnd/bin/python3 /home/admin/XXsendNotification.py mail --cert ${notifyMailToCert} --encrypt ${notifyMailTo} "$2"
/home/admin/python3-env-lnd/bin/python3 /home/admin/XXsendNotification.py mail "${@:3}" --cert ${notifyMailToCert} --encrypt ${notifyMailTo} "$2"
else
/home/admin/python3-env-lnd/bin/python3 /home/admin/XXsendNotification.py mail ${notifyMailTo} "$2"
/home/admin/python3-env-lnd/bin/python3 /home/admin/XXsendNotification.py mail "${@:3}" ${notifyMailTo} "$2"
fi
elif [ "${notifyMethod}" = "slack" ]; then
/home/admin/python3-env-lnd/bin/python3 /home/admin/XXsendNotification.py slack -h "$2"
else
echo "unknown notification method - check /mnt/hdd/raspiblitz.con"
echo "unknown notification method - check /mnt/hdd/raspiblitz.conf"
fi
exit 0