From 4cb3e5482124dc0853003a4a093c38d24f1015a3 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Mon, 31 Aug 2020 17:36:27 +0200 Subject: [PATCH] send at max 1 email / 30 days for DNS issue on custom domain --- app/config.py | 2 ++ cron.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/config.py b/app/config.py index a2602da9..31763cc3 100644 --- a/app/config.py +++ b/app/config.py @@ -295,6 +295,8 @@ ALERT_SPF = "spf" # then later adds this domain into SimpleLogin ALERT_MAILBOX_IS_ALIAS = "mailbox_is_alias" +AlERT_WRONG_MX_RECORD_CUSTOM_DOMAIN = "custom_domain_mx_record_issue" + # <<<<< END ALERT EMAIL >>>> # Disable onboarding emails diff --git a/cron.py b/cron.py index bb60cf77..797c6cf1 100644 --- a/cron.py +++ b/cron.py @@ -15,6 +15,7 @@ from app.config import ( APPLE_API_SECRET, EMAIL_SERVERS_WITH_PRIORITY, URL, + AlERT_WRONG_MX_RECORD_CUSTOM_DOMAIN, ) from app.dns_utils import get_mx_domains from app.email_utils import ( @@ -22,6 +23,7 @@ from app.email_utils import ( send_trial_end_soon_email, render, email_domain_can_be_used_as_mailbox, + send_email_with_rate_control, ) from app.extensions import db from app.log import LOG @@ -337,7 +339,9 @@ def check_custom_domain(): domain_dns_url = f"{URL}/dashboard/domains/{custom_domain.id}/dns" - send_email( + send_email_with_rate_control( + user, + AlERT_WRONG_MX_RECORD_CUSTOM_DOMAIN, user.email, f"Please update {custom_domain.domain} DNS on SimpleLogin", render( @@ -352,6 +356,8 @@ def check_custom_domain(): name=user.name or "", domain_dns_url=domain_dns_url, ), + max_nb_alert=1, + nb_day=30, )