diff --git a/app/email_utils.py b/app/email_utils.py
index 7de12ae0..c6c8fcc4 100644
--- a/app/email_utils.py
+++ b/app/email_utils.py
@@ -38,6 +38,15 @@ def send_welcome_email(user):
)
+def send_trial_end_soon_email(user):
+ send_email(
+ user.email,
+ f"Your trial will end soon {user.name}",
+ _render("trial-end.txt", name=user.name, user=user),
+ _render("trial-end.html", name=user.name, user=user),
+ )
+
+
def send_activation_email(email, name, activation_link):
send_email(
email,
diff --git a/cron.py b/cron.py
index a7ea2367..cc2fae0e 100644
--- a/cron.py
+++ b/cron.py
@@ -1,7 +1,7 @@
import arrow
from app.config import IGNORED_EMAILS, ADMIN_EMAIL
-from app.email_utils import send_email
+from app.email_utils import send_email, send_trial_end_soon_email
from app.extensions import db
from app.log import LOG
from app.models import (
@@ -16,6 +16,13 @@ from app.models import (
from server import create_app
+def send_trial_end_soon():
+ for user in User.query.filter(User.trial_end.isnot(None)).all():
+ if arrow.now().shift(days=3) > user.trial_end >= arrow.now().shift(days=2):
+ LOG.d("Send trial end email to user %s", user)
+ send_trial_end_soon_email(user)
+
+
def stats():
"""send admin stats everyday"""
if not ADMIN_EMAIL:
@@ -103,3 +110,4 @@ if __name__ == "__main__":
with app.app_context():
stats()
+ send_trial_end_soon()
diff --git a/templates/emails/trial-end.html b/templates/emails/trial-end.html
new file mode 100644
index 00000000..f94ff4b0
--- /dev/null
+++ b/templates/emails/trial-end.html
@@ -0,0 +1,25 @@
+{% extends "base.html" %}
+
+{% block content %}
+ {% if name %}
+ {{ render_text("Hi " + name + ",") }}
+ {% else %}
+ {{ render_text("Hi,") }}
+ {% endif %}
+
+ {{ render_text("Your trial will end " + user.trial_end.humanize() + ".") }}
+
+ {{ render_text("When the trial ends:") }}
+
+ {{ render_text("- All aliases/domains/directories you have created and kept and continue working.") }}
+ {{ 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_text('Let me know if you need to extend your trial period.') }}
+
+
+{% endblock %}
+
diff --git a/templates/emails/trial-end.txt b/templates/emails/trial-end.txt
new file mode 100644
index 00000000..fc0120fa
--- /dev/null
+++ b/templates/emails/trial-end.txt
@@ -0,0 +1,17 @@
+Hi {{name}}
+
+Your trial will end {{ user.trial_end.humanize() }}.
+
+When the trial 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).
+
+Let me know if you need to extend your trial period.
+
+Best,
+Son - SimpleLogin founder.