send trial ending reminder when trial ends in 2-3 days

This commit is contained in:
Son NK 2020-01-30 14:19:09 +07:00
parent 9383918e96
commit 8da4557325
4 changed files with 60 additions and 1 deletions

View File

@ -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,

10
cron.py
View File

@ -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()

View File

@ -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 <b>kept</b> 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 <b>catch-all</b> or <b>directory</b> 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 <a href="https://app.simplelogin.io/dashboard/pricing">upgrade</a> 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 %}

View File

@ -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.