Skip to content

Commit e0b11ed

Browse files
committed
WIP HTML mail
1 parent 0320fb3 commit e0b11ed

File tree

7 files changed

+155
-426
lines changed

7 files changed

+155
-426
lines changed

backend/PyMatcha/routes/api/auth.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,30 +94,9 @@ def api_create_user():
9494
raise e
9595
else:
9696
token = generate_confirmation_token(email=data["email"], token_type="confirm")
97-
title = "Confirm your email address"
98-
text1 = "Thank you for registering on PyMatcha !"
99-
text2 = "Please confirm your email address using the following link"
100-
text3 = "Once your email is confirmed, you can log in"
101-
text4 = (
102-
"If the button didn't work, copy and paste this url in your web browser: "
103-
+ os.getenv("APP_URL")
104-
+ "/auth/confirm/"
105-
+ token
106-
)
107-
current_app.logger.debug("New user {} successfully created".format(new_user.email))
108-
buttonlink = os.getenv("APP_URL") + "/auth/confirm/" + token
109-
buttontext = "Confirm my email"
110-
rendered_html = render_template(
111-
"email.html.jinja2",
112-
title=title,
113-
text1=text1,
114-
text2=text2,
115-
text3=text3,
116-
text4=text4,
117-
buttonlink=buttonlink,
118-
buttontext=buttontext,
119-
)
120-
send_mail_html.delay(dest=data["email"], subject=title, html=rendered_html)
97+
link = os.getenv("APP_URL") + "/auth/confirm/" + token
98+
rendered_html = render_template("confirm_email.html.jinja2", link=link)
99+
send_mail_html.delay(dest=data["email"], subject="Confirm your email on PyMatcha", html=rendered_html)
121100
return SuccessOutputMessage("email", new_user.email, "New user successfully created.")
122101

123102

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html style="width:100%;font-family:arial, 'helvetica neue', helvetica, sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;padding:0;Margin:0;">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta content="width=device-width, initial-scale=1" name="viewport">
6+
<meta name="x-apple-disable-message-reformatting">
7+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
8+
<meta content="telephone=no" name="format-detection">
9+
<title>PyMatcha-confirm-email</title>
10+
<!--[if (mso 16)]>
11+
<style type="text/css">
12+
a {text-decoration: none;}
13+
</style>
14+
<![endif]-->
15+
<!--[if gte mso 9]><style>sup { font-size: 100% !important; }</style><![endif]-->
16+
<style type="text/css">
17+
@media only screen and (max-width:600px) {p, ul li, ol li, a { font-size:16px!important; line-height:150%!important } h1 { font-size:30px!important; text-align:center; line-height:120%!important } h2 { font-size:26px!important; text-align:center; line-height:120%!important } h3 { font-size:20px!important; text-align:center; line-height:120%!important } h1 a { font-size:30px!important } h2 a { font-size:26px!important } h3 a { font-size:20px!important } .es-menu td a { font-size:16px!important } .es-header-body p, .es-header-body ul li, .es-header-body ol li, .es-header-body a { font-size:16px!important } .es-footer-body p, .es-footer-body ul li, .es-footer-body ol li, .es-footer-body a { font-size:16px!important } .es-infoblock p, .es-infoblock ul li, .es-infoblock ol li, .es-infoblock a { font-size:12px!important } *[class="gmail-fix"] { display:none!important } .es-m-txt-c, .es-m-txt-c h1, .es-m-txt-c h2, .es-m-txt-c h3 { text-align:center!important } .es-m-txt-r, .es-m-txt-r h1, .es-m-txt-r h2, .es-m-txt-r h3 { text-align:right!important } .es-m-txt-l, .es-m-txt-l h1, .es-m-txt-l h2, .es-m-txt-l h3 { text-align:left!important } .es-m-txt-r img, .es-m-txt-c img, .es-m-txt-l img { display:inline!important } .es-button-border { display:block!important } a.es-button { font-size:20px!important; display:block!important; border-width:10px 0px 10px 0px!important } .es-btn-fw { border-width:10px 0px!important; text-align:center!important } .es-adaptive table, .es-btn-fw, .es-btn-fw-brdr, .es-left, .es-right { width:100%!important } .es-content table, .es-header table, .es-footer table, .es-content, .es-footer, .es-header { width:100%!important; max-width:600px!important } .es-adapt-td { display:block!important; width:100%!important } .adapt-img { width:100%!important; height:auto!important } .es-m-p0 { padding:0px!important } .es-m-p0r { padding-right:0px!important } .es-m-p0l { padding-left:0px!important } .es-m-p0t { padding-top:0px!important } .es-m-p0b { padding-bottom:0!important } .es-m-p20b { padding-bottom:20px!important } .es-mobile-hidden, .es-hidden { display:none!important } .es-desk-hidden { display:table-row!important; width:auto!important; overflow:visible!important; float:none!important; max-height:inherit!important; line-height:inherit!important } .es-desk-menu-hidden { display:table-cell!important } table.es-table-not-adapt, .esd-block-html table { width:auto!important } table.es-social { display:inline-block!important } table.es-social td { display:inline-block!important } }
18+
#outlook a {
19+
padding:0;
20+
}
21+
.ExternalClass {
22+
width:100%;
23+
}
24+
.ExternalClass,
25+
.ExternalClass p,
26+
.ExternalClass span,
27+
.ExternalClass font,
28+
.ExternalClass td,
29+
.ExternalClass div {
30+
line-height:100%;
31+
}
32+
.es-button {
33+
mso-style-priority:100!important;
34+
text-decoration:none!important;
35+
}
36+
a[x-apple-data-detectors] {
37+
color:inherit!important;
38+
text-decoration:none!important;
39+
font-size:inherit!important;
40+
font-family:inherit!important;
41+
font-weight:inherit!important;
42+
line-height:inherit!important;
43+
}
44+
.es-desk-hidden {
45+
display:none;
46+
float:left;
47+
overflow:hidden;
48+
width:0;
49+
max-height:0;
50+
line-height:0;
51+
mso-hide:all;
52+
}
53+
</style>
54+
</head>
55+
<body style="width:100%;font-family:arial, 'helvetica neue', helvetica, sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;padding:0;Margin:0;">
56+
<div class="es-wrapper-color" style="background-color:#F6F6F6;">
57+
<!--[if gte mso 9]>
58+
<v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
59+
<v:fill type="tile" color="#f6f6f6"></v:fill>
60+
</v:background>
61+
<![endif]-->
62+
<table class="es-wrapper" width="100%" cellspacing="0" cellpadding="0" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;padding:0;Margin:0;width:100%;height:100%;background-repeat:repeat;background-position:center top;">
63+
<tr style="border-collapse:collapse;">
64+
<td valign="top" style="padding:0;Margin:0;">
65+
<table class="es-content" cellspacing="0" cellpadding="0" align="center" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;table-layout:fixed !important;width:100%;">
66+
<tr style="border-collapse:collapse;">
67+
<td align="center" style="padding:0;Margin:0;">
68+
<table class="es-content-body" width="600" cellspacing="0" cellpadding="0" bgcolor="#ffffff" align="center" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;background-color:#FFFFFF;">
69+
<tr style="border-collapse:collapse;">
70+
<td align="left" style="Margin:0;padding-top:20px;padding-bottom:20px;padding-left:20px;padding-right:20px;">
71+
<table width="100%" cellspacing="0" cellpadding="0" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;">
72+
<tr style="border-collapse:collapse;">
73+
<td width="560" valign="top" align="center" style="padding:0;Margin:0;">
74+
<table width="100%" cellspacing="0" cellpadding="0" role="presentation" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;">
75+
<tr style="border-collapse:collapse;">
76+
<td align="left" style="padding:0;Margin:0;padding-bottom:15px;"><h2 style="Margin:0;line-height:29px;mso-line-height-rule:exactly;font-family:arial, 'helvetica neue', helvetica, sans-serif;font-size:24px;font-style:normal;font-weight:normal;color:#333333;text-align:center;">Welcome to PyMatcha !<br></h2></td>
77+
</tr>
78+
<tr style="border-collapse:collapse;">
79+
<td align="center" style="padding:0;Margin:0;"><img class="adapt-img" src="https://eziuhk.stripocdn.email/content/guids/CABINET_e354f7736d59c71049f64a7c0364ce24/images/49341582655349409.png" alt style="display:block;border:0;outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;" width="300"></td>
80+
</tr>
81+
<tr style="border-collapse:collapse;">
82+
<td align="center" style="padding:0;Margin:0;padding-top:20px;"><p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-size:20px;font-family:arial, 'helvetica neue', helvetica, sans-serif;line-height:30px;color:#333333;">It is now time for you to confirm your email and fill up your profile !</p></td>
83+
</tr>
84+
<tr style="border-collapse:collapse;">
85+
<td align="center" style="padding:10px;Margin:0;"><span class="es-button-border" style="border-style:solid;border-color:#2CB543;background:#2CB543;border-width:0px 0px 2px 0px;display:inline-block;border-radius:30px;width:auto;"><a href="{{ link }}" class="es-button" target="_blank" style="mso-style-priority:100 !important;text-decoration:none;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:arial, 'helvetica neue', helvetica, sans-serif;font-size:18px;color:#FFFFFF;border-style:solid;border-color:#31CB4B;border-width:10px 20px 10px 20px;display:inline-block;background:#31CB4B;border-radius:30px;font-weight:normal;font-style:normal;line-height:22px;width:auto;text-align:center;">Confirm my email</a></span></td>
86+
</tr>
87+
<tr style="border-collapse:collapse;">
88+
<td align="center" style="padding:0;Margin:0;padding-top:20px;"><p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-size:11px;font-family:arial, 'helvetica neue', helvetica, sans-serif;line-height:17px;color:#333333;">If the link didn't work, copy and paste this url in your web browser {{ link }}</p></td>
89+
</tr>
90+
</table></td>
91+
</tr>
92+
</table></td>
93+
</tr>
94+
</table></td>
95+
</tr>
96+
</table>
97+
<table class="es-footer" cellspacing="0" cellpadding="0" align="center" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;table-layout:fixed !important;width:100%;background-color:transparent;background-repeat:repeat;background-position:center top;">
98+
<tr style="border-collapse:collapse;">
99+
<td align="center" style="padding:0;Margin:0;">
100+
<table class="es-footer-body" width="600" cellspacing="0" cellpadding="0" align="center" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;background-color:transparent;">
101+
<tr style="border-collapse:collapse;">
102+
<td align="left" style="Margin:0;padding-top:20px;padding-bottom:20px;padding-left:20px;padding-right:20px;">
103+
<table width="100%" cellspacing="0" cellpadding="0" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;">
104+
<tr style="border-collapse:collapse;">
105+
<td width="560" valign="top" align="center" style="padding:0;Margin:0;">
106+
<table width="100%" cellspacing="0" cellpadding="0" role="presentation" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;">
107+
<tr style="border-collapse:collapse;">
108+
<td align="center" style="padding:20px;Margin:0;">
109+
<table width="75%" height="100%" cellspacing="0" cellpadding="0" border="0" role="presentation" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;">
110+
<tr style="border-collapse:collapse;">
111+
<td style="padding:0;Margin:0px 0px 0px 0px;border-bottom:1px solid #CCCCCC;background:none;height:1px;width:100%;margin:0px;"></td>
112+
</tr>
113+
</table></td>
114+
</tr>
115+
<tr style="border-collapse:collapse;">
116+
<td align="center" style="padding:0;Margin:0;padding-top:10px;padding-bottom:10px;"><p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-size:11px;font-family:arial, 'helvetica neue', helvetica, sans-serif;line-height:17px;color:#333333;"&nbsp;2020 PyMatcha - by <a target="_blank" href="https://github.com/seluj78/" style="-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:arial, 'helvetica neue', helvetica, sans-serif;font-size:11px;text-decoration:underline;color:#1376C8;">jlasne</a> & <a target="_blank" href="https://github.com/gmorer" style="-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:arial, 'helvetica neue', helvetica, sans-serif;font-size:11px;text-decoration:underline;color:#1376C8;">gmorer</a><br></p></td>
117+
</tr>
118+
</table></td>
119+
</tr>
120+
</table></td>
121+
</tr>
122+
</table></td>
123+
</tr>
124+
</table></td>
125+
</tr>
126+
</table>
127+
</div>
128+
</body>
129+
</html>

0 commit comments

Comments
 (0)