diff --git a/app/__init__.py b/app/__init__.py index 550b84fe..f39b28de 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -97,8 +97,8 @@ def create_app(config_class=Config): secure = () mail_handler = SMTPHandler( mailhost=(app.config['MAIL_SERVER'], app.config['MAIL_PORT']), - fromaddr='rimu@chorebuster.net', - toaddrs=app.config['ADMINS'], subject='CB Failure', + fromaddr='errors@rimu.geek.nz', + toaddrs=app.config['ADMINS'], subject='PieFed error', credentials=auth, secure=secure) mail_handler.setLevel(logging.ERROR) app.logger.addHandler(mail_handler) diff --git a/app/auth/routes.py b/app/auth/routes.py index 04fea620..14f232be 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -106,7 +106,7 @@ def register(): flash(_('Your username contained special letters so it was changed to %(name)s.', name=form.user_name.data), 'warning') user = User(user_name=form.user_name.data, title=form.user_name.data, email=form.real_email.data, verification_token=verification_token, instance_id=1, ip_address=ip_address(), - banned=user_ip_banned() or user_cookie_banned(), email_unread_sent=False, email_messages_sent=False, + banned=user_ip_banned() or user_cookie_banned(), email_unread_sent=False, referrer=session.get('Referer')) user.set_password(form.password.data) db.session.add(user) diff --git a/app/cli.py b/app/cli.py index fef26de8..0d57aec0 100644 --- a/app/cli.py +++ b/app/cli.py @@ -202,8 +202,8 @@ def register(app): posts = posts.limit(20).all() # Send email! - send_email(_('You have unread notifications'), - sender='PieFed ', + send_email(_('[PieFed] You have unread notifications'), + sender=f'PieFed ', 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 59884139..e71fd52a 100644 --- a/app/email.py +++ b/app/email.py @@ -12,7 +12,7 @@ CHARSET = "UTF-8" def send_password_reset_email(user): token = user.get_reset_password_token() send_email(_('[PieFed] Reset Your Password'), - sender='PieFed ', + sender=f'PieFed ', recipients=[user.email], text_body=render_template('email/reset_password.txt', user=user, token=token), @@ -21,8 +21,8 @@ def send_password_reset_email(user): def send_verification_email(user): - send_email(_('Please verify your email address'), - sender='PieFed ', + send_email(_('[PieFed] Please verify your email address'), + sender=f'PieFed ', recipients=[user.email], text_body=render_template('email/verification.txt', user=user), html_body=render_template('email/verification.html', user=user)) @@ -31,7 +31,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='PieFed ', + sender=f'PieFed ', 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)) @@ -39,9 +39,12 @@ 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 ' if type(recipients) == str: recipients = [recipients] with current_app.app_context(): + return_path = 'bounces@' + current_app.config['SERVER_NAME'] try: # Create a new SES resource and specify a region. amazon_client = boto3.client('ses', region_name=AWS_REGION) @@ -63,7 +66,7 @@ def send_async_email(subject, sender, recipients, text_body, html_body, reply_to }, }, Source=sender, - ReturnPath='bounces@chorebuster.net') + ReturnPath=return_path) else: response = amazon_client.send_email( Destination={'ToAddresses': recipients}, @@ -81,7 +84,7 @@ def send_async_email(subject, sender, recipients, text_body, html_body, reply_to }, }, Source=sender, - ReturnPath='bounces@chorebuster.net', + ReturnPath=return_path, ReplyToAddresses=[reply_to]) # message.attach_alternative("...AMPHTML content...", "text/x-amp-html") diff --git a/app/main/routes.py b/app/main/routes.py index 7812b42b..90987f2c 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -289,8 +289,8 @@ def test(): posts = posts.limit(20).all() # Send email! - send_email(_('You have unread notifications'), - sender='PieFed ', + send_email(_('[PieFed] You have unread notifications'), + sender=f'PieFed ', 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, diff --git a/app/templates/email/verification.html b/app/templates/email/verification.html index bdca16ea..1dfb89f3 100644 --- a/app/templates/email/verification.html +++ b/app/templates/email/verification.html @@ -1,11 +1,6 @@

PieFed logo

Hi {{ user.display_name() }},

-

- To verify your email address - - click here - . -

+

Please click this like to verify your email address.

Alternatively, you can paste the following link in your browser's address bar:

{{ url_for('auth.verify_email', token=user.verification_token, _external=True) }}

Thanks,

diff --git a/app/templates/email/verification.txt b/app/templates/email/verification.txt index 5a20744d..36c6379e 100644 --- a/app/templates/email/verification.txt +++ b/app/templates/email/verification.txt @@ -1,6 +1,6 @@ Hello {{ user.display_name() }}, -To verify your email address: +To verify your email address, please open this link: {{ url_for('auth.verify_email', token=user.verification_token, _external=True) }}