diff --git a/cron.py b/cron.py
index 62d850f3..0c1a7d66 100644
--- a/cron.py
+++ b/cron.py
@@ -30,6 +30,25 @@ def notify_trial_end():
send_trial_end_soon_email(user)
+def notify_premium_end():
+ """sent to user who has canceled their subscription and who has their subscription ending soon"""
+ for sub in Subscription.query.filter(Subscription.cancelled == True).all():
+ if (
+ arrow.now().shift(days=3).date()
+ > sub.next_bill_date
+ >= arrow.now().shift(days=2).date()
+ ):
+ user = sub.user
+ LOG.d(f"Send subscription ending soon email to user {user}")
+
+ send_email(
+ user.email,
+ f"Your subscription will end soon {user.name}",
+ render("transactional/subscription-end.txt", user=user),
+ render("transactional/subscription-end.html", user=user),
+ )
+
+
def notify_manual_sub_end():
for manual_sub in ManualSubscription.query.all():
need_reminder = False
@@ -148,7 +167,12 @@ if __name__ == "__main__":
"--job",
help="Choose a cron job to run",
type=str,
- choices=["stats", "notify_trial_end", "notify_manual_subscription_end"],
+ choices=[
+ "stats",
+ "notify_trial_end",
+ "notify_manual_subscription_end",
+ "notify_premium_end",
+ ],
)
args = parser.parse_args()
@@ -164,3 +188,6 @@ if __name__ == "__main__":
elif args.job == "notify_manual_subscription_end":
LOG.d("Notify users with manual subscription ending soon")
notify_manual_sub_end()
+ elif args.job == "notify_premium_end":
+ LOG.d("Notify users with premium ending soon")
+ notify_premium_end()
diff --git a/crontab.yml b/crontab.yml
index fae823b4..6b742e59 100644
--- a/crontab.yml
+++ b/crontab.yml
@@ -16,3 +16,9 @@ jobs:
shell: /bin/bash
schedule: "0 9 * * *"
captureStderr: true
+
+ - name: SimpleLogin Notify Premium Ends
+ command: python /code/cron.py -j notify_premium_end
+ shell: /bin/bash
+ schedule: "0 10 * * *"
+ captureStderr: true
diff --git a/templates/emails/transactional/subscription-end.html b/templates/emails/transactional/subscription-end.html
new file mode 100644
index 00000000..b0eade78
--- /dev/null
+++ b/templates/emails/transactional/subscription-end.html
@@ -0,0 +1,31 @@
+{% extends "base.html" %}
+
+{% block content %}
+ {% if name %}
+ {{ render_text("Hi " + user.name + ",") }}
+ {% else %}
+ {{ render_text("Hi,") }}
+ {% endif %}
+
+ {{ render_text("Your subscription will end on " + user.next_bill_date() + ".") }}
+
+ {{ render_text("When the subscription ends:") }}
+
+ {{ render_text("- All aliases/domains/directories you have created are kept and continue working normally.") }}
+ {{ render_text("- You cannot create new aliases if you exceed the free plan limit, i.e. have more than 5 aliases.") }}
+ {{ render_text("- As features like catch-all or directory allow you to create aliases on-the-fly, those aliases cannot be automatically created if you have more than 5 aliases.") }}
+ {{ render_text("- You cannot add new domain or directory.") }}
+
+ {{ render_text('You can upgrade today to continue using all these Premium features (and much more coming).') }}
+
+ {{ render_button("Upgrade your account", "https://app.simplelogin.io/dashboard/pricing") }}
+
+ {{ render_text('Regardless of your choice, we want to say thank you for trying SimpleLogin. We know the product
+ requires an investment of your time, and we appreciate you giving us a chance.') }}
+ {{ render_text('Thanks,
SimpleLogin Team.') }}
+ {{ render_text('P.S. If you have any questions or need any help, please don\'t hesitate to reach out. You can simply reply to this email or reach us via Twitter/Github.') }}
+ {{ raw_url("https://app.simplelogin.io/dashboard/pricing") }}
+
+
+{% endblock %}
+
diff --git a/templates/emails/transactional/subscription-end.txt b/templates/emails/transactional/subscription-end.txt
new file mode 100644
index 00000000..6668eb49
--- /dev/null
+++ b/templates/emails/transactional/subscription-end.txt
@@ -0,0 +1,15 @@
+Hi {{user.name}}
+
+Your subscription will end on {{ user.next_bill_date() }}.
+
+When the subscription ends:
+
+- All aliases/domains/directories you have created are kept and continue working.
+- You cannot create new aliases if you exceed the free plan limit, i.e. have more than 5 aliases.
+- As features like "catch-all" or "directory" allow you to create aliases on-the-fly, those aliases cannot be automatically created if you have more than 5 aliases.
+- You cannot add new domain or directory.
+
+You can upgrade today to continue using all these Premium features (and much more coming).
+
+Best,
+SimpleLogin Team.