From 3678d41df682f252cf609f1be3ce8e609d7f5091 Mon Sep 17 00:00:00 2001 From: Julian Rother <julian@cccv.de> Date: Tue, 22 Mar 2022 18:09:17 +0100 Subject: [PATCH] Support SMTP without authentication Closes #150 --- uffd/default_config.cfg | 2 +- uffd/sendmail.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/uffd/default_config.cfg b/uffd/default_config.cfg index 6546b002..71bb0f78 100644 --- a/uffd/default_config.cfg +++ b/uffd/default_config.cfg @@ -31,7 +31,7 @@ ACL_SIGNUP_GROUP="uffd_signup" MAIL_SERVER='' # e.g. example.com MAIL_PORT=465 -MAIL_USERNAME='yourId@example.com' +MAIL_USERNAME='yourId@example.com' # set to empty string to disable authentication MAIL_PASSWORD='*****' MAIL_USE_STARTTLS=True MAIL_FROM_ADDRESS='foo@bar.com' diff --git a/uffd/sendmail.py b/uffd/sendmail.py index bf36ea86..83b8960a 100644 --- a/uffd/sendmail.py +++ b/uffd/sendmail.py @@ -24,7 +24,8 @@ def sendmail(addr, subject, template_name, **kwargs): server = smtplib.SMTP(host=current_app.config['MAIL_SERVER'], port=current_app.config['MAIL_PORT']) if current_app.config['MAIL_USE_STARTTLS']: server.starttls() - server.login(current_app.config['MAIL_USERNAME'], current_app.config['MAIL_PASSWORD']) + if current_app.config['MAIL_USERNAME']: + server.login(current_app.config['MAIL_USERNAME'], current_app.config['MAIL_PASSWORD']) server.send_message(msg) server.quit() if current_app.debug: -- GitLab