SMTP_LOGIN can be set to "", meaning that the smtp server does not want authentication (#103)

Co-authored-by: Emmanuel <emmanuel.courcelle@zaclys.net>
This commit is contained in:
manu5801 2022-02-21 18:28:51 +01:00 committed by GitHub
parent 79d4e22601
commit 78c501da98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,16 +18,27 @@ def send(to, subject, body, html=None, copy=None, attachments=None, mail_from=No
body = body.replace("https", "http") body = body.replace("https", "http")
return print("Sending email", str(body.encode('utf-8')), flush=True) return print("Sending email", str(body.encode('utf-8')), flush=True)
message.send( # if no SMTP_LOGIN specified, don't create user and password fields, as the smtp server don't want them !
to=to, if config.SMTP_LOGIN=="":
mail_from=mail_from, smtp={
"host": config.SMTP_HOST,
"port": "25",
"ssl": False,
}
else:
smtp={ smtp={
"host": config.SMTP_HOST, "host": config.SMTP_HOST,
"user": config.SMTP_LOGIN, "user": config.SMTP_LOGIN,
"password": config.SMTP_PASSWORD, "password": config.SMTP_PASSWORD,
"port": "465", "port": "25",
"ssl": True, "ssl": False,
}, }
message.send(
to=to,
mail_from=mail_from,
smtp=smtp
) )