From cff0e86fd974fc0c9f9d3972061c5d6d43976e77 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 12 Jul 2023 12:36:41 +0200 Subject: [PATCH] Email settings: Block with invalid SPF setup (#3471) --- .../pretixcontrol/email_setup_simple.html | 20 +++++++++++++------ src/pretix/control/views/mailsetup.py | 9 +++++---- src/tests/control/test_events.py | 2 +- src/tests/control/test_organizer.py | 2 +- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/pretix/control/templates/pretixcontrol/email_setup_simple.html b/src/pretix/control/templates/pretixcontrol/email_setup_simple.html index 05ec59d8ed..c37e07b45d 100644 --- a/src/pretix/control/templates/pretixcontrol/email_setup_simple.html +++ b/src/pretix/control/templates/pretixcontrol/email_setup_simple.html @@ -20,7 +20,7 @@
{% if spf_warning %} -
+

{{ spf_warning }}

@@ -70,10 +70,18 @@
-
- -
+ {% if spf_warning %} + + {% else %} +
+ +
+ {% endif %} {% endblock %} diff --git a/src/pretix/control/views/mailsetup.py b/src/pretix/control/views/mailsetup.py index 4a4cf01b2a..eca96a4051 100644 --- a/src/pretix/control/views/mailsetup.py +++ b/src/pretix/control/views/mailsetup.py @@ -192,8 +192,8 @@ class MailSettingsSetupView(TemplateView): spf_record = get_spf_record(hostname) if not spf_record: spf_warning = _( - 'We could not find an SPF record set for the domain you are trying to use. You can still ' - 'proceed, but it will increase the chance of emails going to spam or being rejected. We ' + 'We could not find an SPF record set for the domain you are trying to use. This means that ' + 'there is a very high change most of the emails will be rejected or markes as spam. We ' 'strongly recommend setting an SPF record on the domain. You can do so through the DNS ' 'settings at the provider you registered your domain with.' ) @@ -205,7 +205,8 @@ class MailSettingsSetupView(TemplateView): 'this system in the SPF record.' ) - if settings.MAIL_CUSTOM_SENDER_VERIFICATION_REQUIRED: + verification = settings.MAIL_CUSTOM_SENDER_VERIFICATION_REQUIRED and not spf_warning + if verification: if 'verification' in self.request.POST: messages.error(request, _('The verification code was incorrect, please try again.')) else: @@ -230,7 +231,7 @@ class MailSettingsSetupView(TemplateView): context={ 'basetpl': self.basetpl, 'object': self.object, - 'verification': settings.MAIL_CUSTOM_SENDER_VERIFICATION_REQUIRED, + 'verification': verification, 'spf_warning': spf_warning, 'spf_record': spf_record, 'spf_key': settings.MAIL_CUSTOM_SENDER_SPF_STRING, diff --git a/src/tests/control/test_events.py b/src/tests/control/test_events.py index 6072b398c3..d6d98a58d2 100644 --- a/src/tests/control/test_events.py +++ b/src/tests/control/test_events.py @@ -633,7 +633,7 @@ class EventsTest(SoupTest): }, follow=True ) - assert doc.select('.alert-warning') + assert doc.select('.alert-danger') self.event1.settings.flush() # not yet saved assert "mail_from" not in self.event1.settings._cache() diff --git a/src/tests/control/test_organizer.py b/src/tests/control/test_organizer.py index 28538c2680..fe4b336563 100644 --- a/src/tests/control/test_organizer.py +++ b/src/tests/control/test_organizer.py @@ -221,7 +221,7 @@ class OrganizerTest(SoupTest): }, follow=True ) - assert doc.select('.alert-warning') + assert doc.select('.alert-danger') self.orga1.settings.flush() # not yet saved assert "mail_from" not in self.orga1.settings._cache()