aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-07-04 18:18:26 +0530
committerBobby <[email protected]>2022-07-04 18:18:26 +0530
commitde994764b87d2716f951941f26a1044aaca63ed7 (patch)
treeb4645d1a48bfc337cb29fe5956ccdea5fdd824ed
parent36760819702c43670e69373e13aea25de35695de (diff)
downloadthatcomputerscientist-de994764b87d2716f951941f26a1044aaca63ed7.tar.xz
thatcomputerscientist-de994764b87d2716f951941f26a1044aaca63ed7.zip
Update email sending via domain and email template
-rw-r--r--README.md2
-rw-r--r--routes/account.routes.js36
-rw-r--r--views/account.ejs4
3 files changed, 24 insertions, 18 deletions
diff --git a/README.md b/README.md
index ca602672..773a65b7 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ If you would like to contribute to the website, please see the [contributing gui
Below is the screenshot of how the website looks like right now. This screenshot is being updated programatically by [That Computer Scientist's Screenshot API](https://api.thatcomputerscientist.com/screenshot), and will update as I push more changes to the repository.
-![Screenshot](https://api.thatcomputerscientist.com/screenshot?random=0.05595404856210995)
+![Screenshot](https://api.thatcomputerscientist.com/screenshot?random=0.2128385904744179)
## Cloning, Installing, and Running
diff --git a/routes/account.routes.js b/routes/account.routes.js
index b07c7d40..5640e082 100644
--- a/routes/account.routes.js
+++ b/routes/account.routes.js
@@ -33,7 +33,13 @@ router.get("/", (req, res) => {
avatar: md5(user.gravatarEmail || user.email || ""),
url:
user.public == 1
- ? `${req.protocol + "://" + user.username + '.' + req.get("host")}`.replace('www.', '')
+ ? `${
+ req.protocol +
+ "://" +
+ user.username +
+ "." +
+ req.get("host")
+ }`.replace("www.", "")
: "",
},
});
@@ -56,7 +62,7 @@ router.post("/sendVerificationEmail", (req, res) => {
process.env.AUTHORIZATION_STRING,
(err, decoded) => {
if (err) {
- renderRoute(req, res, "errors/page_error", "Error", false, {
+ renderRoute(req, res, "errors/page_error", "Error", false, {
error: err,
});
} else {
@@ -88,7 +94,9 @@ router.post("/sendVerificationEmail", (req, res) => {
res.redirect(req.get("referer"));
} else {
const transporter = nodemailer.createTransport({
- service: "gmail",
+ host: process.env.MAIL_HOST,
+ secure: true,
+ port: 465,
auth: {
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASSWORD,
@@ -108,23 +116,21 @@ router.post("/sendVerificationEmail", (req, res) => {
}
)}`;
const mailOptions = {
- from: process.env.EMAIL_USER,
+ from: {
+ name: "That Computer Scientist",
+ address: process.env.EMAIL_USER,
+ },
to: newEmail,
priority: "high",
- subject:
- "[That Computer Scientist] Request to change your email address",
- html: `<p>Hi ${user.firstname || user.username},</p>
- <p>We received a request to change your email address to <em><u>${newEmail}</u></em>.</p>
- <p>If you made this request, please click the link below to verify your new email address:</p>
- <p><a href="${verificationUrl}">${verificationUrl}</a>.</p>
- <p>Please note that this link expires in 1 hour. You might need to make another request if you do not verify the email in the requested time frame. If you did not make this request, you can ignore this email.</p>
- <hr>
- <p>Thanks,</p>
- <p>Kumar Priyansh</p>
- <p>That Computer Scientist</p>`,
+ subject: "Request to change your email address",
+ html: `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:o="urn:schemas-microsoft-com:office:office" style="font-family:'times new roman', times, baskerville, georgia, serif"> <head> <meta charset="UTF-8"> <meta content="width=device-width, initial-scale=1" name="viewport"> <meta name="x-apple-disable-message-reformatting"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="telephone=no" name="format-detection"> <title>Confirm Your Email</title><!--[if (mso 16)]> <style type="text/css"> a{text-decoration: none;}</style><![endif]--><!--[if gte mso 9]> <xml> <o:OfficeDocumentSettings> <o:AllowPNG></o:AllowPNG> <o:PixelsPerInch>96</o:PixelsPerInch> </o:OfficeDocumentSettings> </xml><![endif]--> <style type="text/css"> #outlook a{padding:0;}.es-button{mso-style-priority:100!important; text-decoration:none!important;}a[x-apple-data-detectors]{color:inherit!important; text-decoration:none!important; font-size:inherit!important; font-family:inherit!important; font-weight:inherit!important; line-height:inherit!important;}.es-desk-hidden{display:none; float:left; overflow:hidden; width:0; max-height:0; line-height:0; mso-hide:all;}[data-ogsb] .es-button{border-width:0!important; padding:10px 30px 10px 30px!important;}@media only screen and (max-width:600px){p, ul li, ol li, a{line-height:150%!important}h1, h2, h3, h1 a, h2 a, h3 a{line-height:120%}h1{font-size:36px!important; text-align:left}h2{font-size:26px!important; text-align:left}h3{font-size:20px!important; text-align:left}.es-header-body h1 a, .es-content-body h1 a, .es-footer-body h1 a{font-size:36px!important; text-align:left}.es-header-body h2 a, .es-content-body h2 a, .es-footer-body h2 a{font-size:26px!important; text-align:left}.es-header-body h3 a, .es-content-body h3 a, .es-footer-body h3 a{font-size:20px!important; text-align:left}.es-menu td a{font-size:12px!important}.es-header-body p, .es-header-body ul li, .es-header-body ol li, .es-header-body a{font-size:14px!important}.es-content-body p, .es-content-body ul li, .es-content-body ol li, .es-content-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:14px!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:inline-block!important}a.es-button, button.es-button{font-size:20px!important; display:inline-block!important}.es-adaptive table, .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:0!important}.es-m-p0r{padding-right:0!important}.es-m-p0l{padding-left:0!important}.es-m-p0t{padding-top:0!important}.es-m-p0b{padding-bottom:0!important}.es-m-p20b{padding-bottom:20px!important}.es-mobile-hidden, .es-hidden{display:none!important}tr.es-desk-hidden, td.es-desk-hidden, table.es-desk-hidden{width:auto!important; overflow:visible!important; float:none!important; max-height:inherit!important; line-height:inherit!important}tr.es-desk-hidden{display:table-row!important}table.es-desk-hidden{display:table!important}td.es-desk-menu-hidden{display:table-cell!important}.es-menu td{width:1%!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}.es-m-p5{padding:5px!important}.es-m-p5t{padding-top:5px!important}.es-m-p5b{padding-bottom:5px!important}.es-m-p5r{padding-right:5px!important}.es-m-p5l{padding-left:5px!important}.es-m-p10{padding:10px!important}.es-m-p10t{padding-top:10px!important}.es-m-p10b{padding-bottom:10px!important}.es-m-p10r{padding-right:10px!important}.es-m-p10l{padding-left:10px!important}.es-m-p15{padding:15px!important}.es-m-p15t{padding-top:15px!important}.es-m-p15b{padding-bottom:15px!important}.es-m-p15r{padding-right:15px!important}.es-m-p15l{padding-left:15px!important}.es-m-p20{padding:20px!important}.es-m-p20t{padding-top:20px!important}.es-m-p20r{padding-right:20px!important}.es-m-p20l{padding-left:20px!important}.es-m-p25{padding:25px!important}.es-m-p25t{padding-top:25px!important}.es-m-p25b{padding-bottom:25px!important}.es-m-p25r{padding-right:25px!important}.es-m-p25l{padding-left:25px!important}.es-m-p30{padding:30px!important}.es-m-p30t{padding-top:30px!important}.es-m-p30b{padding-bottom:30px!important}.es-m-p30r{padding-right:30px!important}.es-m-p30l{padding-left:30px!important}.es-m-p35{padding:35px!important}.es-m-p35t{padding-top:35px!important}.es-m-p35b{padding-bottom:35px!important}.es-m-p35r{padding-right:35px!important}.es-m-p35l{padding-left:35px!important}.es-m-p40{padding:40px!important}.es-m-p40t{padding-top:40px!important}.es-m-p40b{padding-bottom:40px!important}.es-m-p40r{padding-right:40px!important}.es-m-p40l{padding-left:40px!important}.es-desk-hidden{display:table-row!important; width:auto!important; overflow:visible!important; max-height:inherit!important}}@media print{.ms-editor-squiggler{display:none !important;}}.ms-editor-squiggler{all: initial; display: block !important; height: 0px !important; width: 0px !important;}@media print{.ms-editor-squiggler{display:none !important;}}.ms-editor-squiggler{all: initial; display: block !important; height: 0px !important; width: 0px !important;}</style> </head> <body class="ms-Fabric--isFocusVisible" style="width:100%;font-family:'times new roman', times, baskerville, georgia, serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;padding:0;Margin:0"> <div class="es-wrapper-color" style="background-color:#fff"><!--[if gte mso 9]> <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t"> <v:fill type="tile" color="#fff"></v:fill> </v:background><![endif]--><!-- <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;background-color:#fff"> <tr> <td valign="top" style="padding:0;Margin:0"> <table cellpadding="0" cellspacing="0" class="es-header" 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"> --><!-- </table></td></tr></table> --> <table cellpadding="0" cellspacing="0" class="es-content" align="center" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;table-layout:fixed !important;width:100%"> <tr> <td align="center" style="padding:0;Margin:0"> <table bgcolor="#ffffff" class="es-content-body" align="center" cellpadding="0" cellspacing="0" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;background-color:#FFFFFF;width:600px"> <tr> <td align="left" style="Margin:0;padding-left:20px;padding-right:20px;padding-top:30px;padding-bottom:30px"> <table cellpadding="0" cellspacing="0" width="100%" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px"> <tr> <td align="center" valign="top" style="padding:0;Margin:0;width:560px"><editor-squiggler style="height:0px;width:0px"> <div class="ms-editor-squiggler"></div></editor-squiggler><editor-squiggler style="height:0px;width:0px"> <div class="ms-editor-squiggler"></div></editor-squiggler> <table cellpadding="0" cellspacing="0" width="100%" role="presentation" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px"> <tr> <td align="center" style="padding:0;Margin:0;padding-top:10px;padding-bottom:10px;font-size:0px"><img src="https://win98icons.alexmeub.com/icons/png/mailbox_world-2.png" alt style="display:block;border:0;outline:none;text-decoration:none;-ms-interpolation-mode:bicubic" width="80" height="80"></td></tr><tr> <td align="center" class="es-m-txt-c" spellcheck="false" data-ms-editor="true" style="padding:0;Margin:0;padding-bottom:10px"><h1 style="Margin:0;line-height:32px;mso-line-height-rule:exactly;font-family:'times new roman', times, baskerville, georgia, serif;font-size:32px;font-style:normal;font-weight:bold;color:#333333">Confirm Your Email</h1></td></tr><tr> <td align="left" class="es-m-p0r es-m-p0l" spellcheck="false" data-ms-editor="true" style="Margin:0;padding-top:5px;padding-bottom:5px;padding-left:40px;padding-right:40px"><p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:'times new roman', times, baskerville, georgia, serif;line-height:21px;color:#333333;font-size:14px">Hi ${
+ user.firstname || user.username
+ },<br><br></p><p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:'times new roman', times, baskerville, georgia, serif;line-height:21px;color:#333333;font-size:14px">We received a request to change your email address to <em><u>${newEmail}</u></em>.<br><br></p><p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:'times new roman', times, baskerville, georgia, serif;line-height:21px;color:#333333;font-size:14px">If you made this request, please click this link&nbsp;to verify your new email address:&nbsp;<a href="${verificationUrl}">${verificationUrl}</a>.<br><br></p><p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:'times new roman', times, baskerville, georgia, serif;line-height:21px;color:#333333;font-size:14px">Please note that this link expires in 1 hour. You might need to make another request if you do not verify the email in the requested period. If you did not make this request, you can ignore this email.<br><br>Once confirmed, this email will be uniquely associated with your account.<br><br>Please do not reply to this email. If you have any questions, please contact us at&nbsp;<a target="_blank" href="mailto:[email protected]" style="-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;text-decoration:underline;color:#5C68E2;font-size:14px">[email protected]</a>.<br></p></td></tr><tr> <td style="padding:0;Margin:0"> <br><hr style="Margin:0"></td></tr><tr> <td align="left" class="es-m-p0r es-m-p0l" spellcheck="false" data-ms-editor="true" style="Margin:0;padding-top:5px;padding-bottom:5px;padding-left:40px;padding-right:40px"><p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:'times new roman', times, baskerville, georgia, serif;line-height:21px;color:#333333;font-size:14px"><br>Thanks,</p><p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:'times new roman', times, baskerville, georgia, serif;line-height:21px;color:#333333;font-size:14px">Kumar Priyansh</p><p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:'times new roman', times, baskerville, georgia, serif;line-height:21px;color:#333333;font-size:14px">That Computer Scientist</p></td></tr></table></td></tr></table></td></tr><tr> <td align="center" style="padding:0;Margin:0"> <table bgcolor="#ffffff" class="es-header-body" align="center" cellpadding="0" cellspacing="0" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;background-color:transparent;width:600px"> <tr> <td align="left" style="Margin:0;padding-top:10px;padding-bottom:10px;padding-left:20px;padding-right:20px"> <table cellpadding="0" cellspacing="0" width="100%" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px"> <tr> <td class="es-m-p0r" valign="top" align="center" style="padding:0;Margin:0;width:560px"> <table cellpadding="0" cellspacing="0" width="100%" role="presentation" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px"> <tr> <td align="center" style="padding:0;Margin:0;padding-bottom:20px;font-size:0px"><img src="https://wrrqeu.stripocdn.email/content/guids/CABINET_d783d4da58c395ffada2abb064ce21f9/images/logo.png" alt="Logo" style="display:block;border:0;outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;font-size:12px" width="200" title="Logo" height="65"></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table> </body> </html>
+ `,
};
transporter.sendMail(mailOptions, (err, info) => {
if (err) {
+ console.log(err);
req.flash(
"mailsenderror",
"Error sending verification email. Please try again later."
diff --git a/views/account.ejs b/views/account.ejs
index c148931a..feb59a37 100644
--- a/views/account.ejs
+++ b/views/account.ejs
@@ -1,10 +1,10 @@
<%- include('partials/header.ejs') %> <%- include('partials/sidebar.ejs') %>
<div class="main">
<h1>My Account</h1>
- <p>You can change account settings for <strong><%= user.username %></strong> here. If you wish to have additional support, please contact me at <a href="mailto:[email protected]?subject=[URGENT]%20Support%20Request%20for%20<%= user.username %>">[email protected]</a>. Please take care of the following points before you submit your support request:</p>
+ <p>You can change account settings for <strong><%= user.username %></strong> here. If you wish to have additional support, please contact me at <a href="mailto:[email protected]?subject=[URGENT]%20Support%20Request%20for%20<%= user.username %>">[email protected]</a>. Please take care of the following points before you submit your support request:</p>
<ul>
<li>Please do not edit the subject line.</li>
- <li>This is a personal email address. Please refrain yourself from spamming.</li>
+ <li>As an individual monitoring this email, I request you to refrain yourself from spamming.</li>
<li>Please do not include any sensitive information (like credit card numbers, passwords, etc.) in the email.</li>
<li>Allow me upto 48 hours to respond to your support request.</li>
<li>Do not send multiple support requests.</li>