From bde463cc1e977d6d1249b54a49b8b3e80dba20e0 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Wed, 26 Jun 2024 10:21:39 +0200 Subject: [PATCH] make all email come from MAIL_FROM, closes #220 --- app/admin/util.py | 2 +- app/cli.py | 2 +- app/email.py | 8 ++++---- app/main/routes.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/admin/util.py b/app/admin/util.py index b22684d1..dd456554 100644 --- a/app/admin/util.py +++ b/app/admin/util.py @@ -100,7 +100,7 @@ def send_newsletter(form): else: to = recipient.email - send_email(subject=form.subject.data, sender=f'{g.site.name} ', recipients=[to], + send_email(subject=form.subject.data, sender=f'{g.site.name} <{current_app.config["MAIL_FROM"]}>', recipients=[to], text_body=body_text, html_body=body_html) if form.test.data: diff --git a/app/cli.py b/app/cli.py index 318d834a..cd35166d 100644 --- a/app/cli.py +++ b/app/cli.py @@ -341,7 +341,7 @@ def register(app): # Send email! send_email(_('[PieFed] You have unread notifications'), - sender=f'PieFed ', + sender=f'{g.site.name} <{current_app.config["MAIL_FROM"]}>', recipients=[user.email], text_body=flask.render_template('email/unread_notifications.txt', user=user, notifications=notifications), diff --git a/app/email.py b/app/email.py index 6f4fdee3..fd659ca2 100644 --- a/app/email.py +++ b/app/email.py @@ -14,7 +14,7 @@ CHARSET = "UTF-8" def send_password_reset_email(user): token = user.get_reset_password_token() send_email(_('[PieFed] Reset Your Password'), - sender=f'PieFed ', + sender=f'{g.site.name} <{current_app.config["MAIL_FROM"]}>', recipients=[user.email], text_body=render_template('email/reset_password.txt', user=user, token=token), @@ -24,7 +24,7 @@ def send_password_reset_email(user): def send_verification_email(user): send_email(_('[PieFed] Please verify your email address'), - sender=f'PieFed ', + sender=f'{g.site.name} <{current_app.config["MAIL_FROM"]}>', recipients=[user.email], text_body=render_template('email/verification.txt', user=user), html_body=render_template('email/verification.html', user=user)) @@ -33,7 +33,7 @@ def send_verification_email(user): def send_welcome_email(user, application_required): subject = _('Your application has been approved - welcome to PieFed') if application_required else _('Welcome to PieFed') send_email(subject, - sender=f'PieFed <{g.site.contact_email}>', + sender=f'{g.site.name} <{current_app.config["MAIL_FROM"]}>', recipients=[user.email], text_body=render_template('email/welcome.txt', user=user, application_required=application_required), html_body=render_template('email/welcome.html', user=user, application_required=application_required)) @@ -42,7 +42,7 @@ def send_welcome_email(user, application_required): @celery.task def send_async_email(subject, sender, recipients, text_body, html_body, reply_to): if 'ngrok.app' in sender: # for local development - sender = 'PieFed ' + sender = f'{g.site.name} <{current_app.config["MAIL_FROM"]}>' return_path = 'bounces@piefed.social' else: return_path = 'bounces@' + current_app.config['SERVER_NAME'] diff --git a/app/main/routes.py b/app/main/routes.py index 79288a50..e7374fbb 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -440,7 +440,7 @@ def test(): # Send email! send_email(_('[PieFed] You have unread notifications'), - sender=f'PieFed ', + sender=f'{g.site.name} <{current_app.config["MAIL_FROM"]}>', recipients=[user.email], text_body=flask.render_template('email/unread_notifications.txt', user=user, notifications=notifications), html_body=flask.render_template('email/unread_notifications.html', user=user,