send mailbox onboarding email

This commit is contained in:
Son NK 2020-03-24 21:19:45 +01:00
parent c02b8298fc
commit 9e04081186
5 changed files with 87 additions and 2 deletions

View file

@ -195,6 +195,7 @@ FLASK_PROFILER_PASSWORD = os.environ.get("FLASK_PROFILER_PASSWORD")
# Job names
JOB_ONBOARDING_1 = "onboarding-1"
JOB_ONBOARDING_2 = "onboarding-2"
JOB_ONBOARDING_3 = "onboarding-3"
# for pagination
PAGE_LIMIT = 20

View file

@ -18,6 +18,7 @@ from app.config import (
AVATAR_URL_EXPIRATION,
JOB_ONBOARDING_1,
JOB_ONBOARDING_2,
JOB_ONBOARDING_3,
)
from app.extensions import db
from app.log import LOG
@ -175,6 +176,11 @@ class User(db.Model, ModelMixin, UserMixin):
payload={"user_id": user.id},
run_at=arrow.now().shift(days=2),
)
Job.create(
name=JOB_ONBOARDING_3,
payload={"user_id": user.id},
run_at=arrow.now().shift(days=3),
)
db.session.flush()
return user

View file

@ -6,7 +6,7 @@ import time
import arrow
from app.config import JOB_ONBOARDING_1, JOB_ONBOARDING_2
from app.config import JOB_ONBOARDING_1, JOB_ONBOARDING_2, JOB_ONBOARDING_3
from app.email_utils import send_email, render
from app.extensions import db
from app.log import LOG
@ -42,12 +42,21 @@ def onboarding_send_from_alias(user):
def onboarding_pgp(user):
send_email(
user.email,
f"Do you know you can encrypt your emails so only you can read them",
f"Do you know you can encrypt your emails so only you can read them?",
render("com/onboarding/pgp.txt", user=user),
render("com/onboarding/pgp.html", user=user),
)
def onboarding_mailbox(user):
send_email(
user.email,
f"Do you know SimpleLogin can manage several email addresses?",
render("com/onboarding/mailbox.txt", user=user),
render("com/onboarding/mailbox.html", user=user),
)
if __name__ == "__main__":
while True:
# run a job 1h earlier or later is not a big deal ...
@ -84,6 +93,15 @@ if __name__ == "__main__":
if user and user.notification and user.activated:
LOG.d("send onboarding pgp email to user %s", user)
onboarding_pgp(user)
elif job.name == JOB_ONBOARDING_3:
user_id = job.payload.get("user_id")
user = User.get(user_id)
# user might delete their account in the meantime
# or disable the notification
if user and user.notification and user.activated:
LOG.d("send onboarding mailbox email to user %s", user)
onboarding_mailbox(user)
else:
LOG.error("Unknown job name %s", job.name)

View file

@ -0,0 +1,34 @@
{% extends "base.html" %}
{% block content %}
{{ render_text("Hi " + user.name) }}
{{ render_text("If you have several email addresses, e.g. Gmail for work and Protonmail for personal stuffs, you can add them into SimpleLogin and create aliases for them.") }}
{{ render_text("A real email address is called <b>mailbox</b> in SimpleLogin.") }}
<img src="https://simplelogin.io/blog/mailbox-gmail.png" alt="Mailbox Gmail">
<img src="https://simplelogin.io/blog/mailbox-protonmail.png" alt="Mailbox Protonmail">
{{ render_text("When creating an alias, you can choose which mailbox that <b>owns</b> this alias, meaning:") }}
{{ render_text("1. Emails sent to this alias are *forwarded* to the owning mailbox.") }}
{{ render_text("2. The owning mailbox can *send* or reply emails from this alias.") }}
{{ render_text("You can also change the owning mailbox for an existing alias.") }}
{{ render_text('The mailbox doesn\'t have to be your personal email: you can also create aliases for your friend by adding his/her email as a mailbox.') }}
{{ render_button("Create mailbox", "https://app.simplelogin.io/dashboard/mailbox") }}
{{ render_text('Thanks, <br />SimpleLogin Team.') }}
{{ render_text('<strong>P.S.</strong> Need immediate help getting started? Just reply to this email, the SimpleLogin support team is always ready to help!.') }}
{{ raw_url("https://app.simplelogin.io/dashboard/mailbox") }}
{% endblock %}
{% block footer %}
This email is sent to {{ user.email }} and is part of our onboarding series. Unsubscribe on
<a href="https://app.simplelogin.io/dashboard/setting#notification">Settings</a>
{% endblock %}

View file

@ -0,0 +1,26 @@
This email is sent to {{ user.email }} and is part of our onboarding series.
Unsubscribe from our emails on https://app.simplelogin.io/dashboard/setting#notification
----------------
Hi {{user.name}}
If you have several email addresses, e.g. Gmail for work and Protonmail for personal stuffs, you can add them into SimpleLogin and create aliases for them.
A (real) email address is called *mailbox* in SimpleLogin.
When creating an alias, you can choose which mailbox that *owns* this alias, meaning:
- emails sent to this alias are *forwarded* to the owning mailbox.
- the owning mailbox can *send* or reply emails from this alias.
You can also change the owning mailbox for an existing alias.
The mailbox doesn't have to be your personal email: you can also create aliases for your friend by adding his/her email as a mailbox.
Start create you mailbox on https://app.simplelogin.io/dashboard/mailbox
As usual, let us know if you have any question by replying to this email.
Best regards,
SimpleLogin team.