Update eMail.py

Using only SMTP via SSL can lead to errors depending on the configuration of the mail server
As there is no switch in the config file (which is good so) the approach is to use SSL first and, if this fails, switch to non-SSL connection.

Due to the importance of this plugin the pull request is affecting the master-branch.
This commit is contained in:
Florian 2017-01-16 21:20:14 +01:00 committed by GitHub
parent ec31cfdbc5
commit 8cdfef4bce

View file

@ -103,7 +103,10 @@ def run(typ,freq,data):
#
# connect to SMTP-Server
#
server = smtplib.SMTP_SSL(globalVars.config.get("eMail", "smtp_server"), globalVars.config.get("eMail", "smtp_port"))
try:
server = smtplib.SMTP_SSL(globalVars.config.get("eMail", "smtp_server"), globalVars.config.get("eMail", "smtp_port"))
except:
server = smtplib.SMTP(globalVars.config.get("eMail", "smtp_server"), globalVars.config.get("eMail", "smtp_port"))
# debug-level to shell (0=no debug|1)
server.set_debuglevel(0)