Mail improvements (#1545)

This commit is contained in:
Dennis Reimann 2020-09-15 13:54:29 +02:00 committed by GitHub
parent a9a5d9bb8e
commit a7acd780fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -107,7 +107,7 @@ def mail(recipient: str = None, message: str = None, subject: str = None, cert:
'From: {} <{}>'.format(from_name, from_address), 'From: {} <{}>'.format(from_name, from_address),
"Subject: {}".format(subject), "Subject: {}".format(subject),
"", "",
"{}".format(message) "{}".format(message.encode('utf8'))
] ]
with open(cert, 'rb') as pem: with open(cert, 'rb') as pem:
@ -122,7 +122,7 @@ def mail(recipient: str = None, message: str = None, subject: str = None, cert:
msg['From'] = '{} <{}>'.format(from_name, from_address), msg['From'] = '{} <{}>'.format(from_name, from_address),
msg['To'] = recipient msg['To'] = recipient
msg.set_payload(message) msg.set_payload(message.encode('utf8'))
msg_to_send = msg.as_bytes() msg_to_send = msg.as_bytes()
# send message via e-Mail # send message via e-Mail

View File

@ -146,9 +146,9 @@ if [ "$1" = "send" ]; then
/usr/bin/python3 /home/admin/XXsendNotification.py ext ${notifyExtCmd} "$2" /usr/bin/python3 /home/admin/XXsendNotification.py ext ${notifyExtCmd} "$2"
elif [ "${notifyMethod}" = "mail" ]; then elif [ "${notifyMethod}" = "mail" ]; then
if [ "${notifyMailEncrypt}" = "on" ]; then if [ "${notifyMailEncrypt}" = "on" ]; then
/usr/bin/python3 /home/admin/XXsendNotification.py mail "${@:3}" --from-address "${notifyMailFromAddress}" --from-name "${notifyMailFromName}" --cert "${notifyMailToCert}" --encrypt ${notifyMailTo} "$2" /usr/bin/python3 /home/admin/XXsendNotification.py mail --from-address "${notifyMailFromAddress}" --from-name "${notifyMailFromName}" --cert "${notifyMailToCert}" --encrypt ${notifyMailTo} "${@:3}" "$2"
else else
/usr/bin/python3 /home/admin/XXsendNotification.py mail "${@:3}" --from-address "${notifyMailFromAddress}" --from-name "${notifyMailFromName}" "${notifyMailTo}" "$2" /usr/bin/python3 /home/admin/XXsendNotification.py mail --from-address "${notifyMailFromAddress}" --from-name "${notifyMailFromName}" "${notifyMailTo}" "${@:3}" "$2"
fi fi
elif [ "${notifyMethod}" = "slack" ]; then elif [ "${notifyMethod}" = "slack" ]; then
/usr/bin/python3 /home/admin/XXsendNotification.py slack -h "$2" /usr/bin/python3 /home/admin/XXsendNotification.py slack -h "$2"