Finalise register mail templates

This commit is contained in:
Fred Boniface 2023-04-04 17:17:12 +01:00
parent fceee0b4ea
commit 79d3ff2d9c
3 changed files with 54 additions and 19 deletions

View File

@ -1,14 +1,20 @@
<html lang="en" style="background-color: grey; width: 100%;"> <html lang="en" style="background-color: grey; width: 100%;">
<head> <head>
<title>OwlBoard - Register</title> <title>OwlBoard - Register</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style> <style>
html { html {
background-color: #2b343c; background-color: #404c55;
background-image: radial-gradient(#2b343c,#404c55);
}
a {
color: white;
} }
</style> </style>
</head> </head>
<body> <body>
<table style="width: 100%; text-align: center; color: white"> <br><br>
<table style="width: 100%; text-align: center; color: azure; font-family: sans-serif;">
<tr> <tr>
<td> <td>
<img src="https://owlboard.info/images/logo/wide_logo.svg" style="height: 100px"> <img src="https://owlboard.info/images/logo/wide_logo.svg" style="height: 100px">
@ -17,15 +23,22 @@
<tr> <tr>
<td> <td>
<h1 style="color: #00b7b7">Register for OwlBoard</h1> <h1 style="color: #00b7b7">Register for OwlBoard</h1>
<p>Use the link below to register for OwlBoard (Staff Version)</p>
<a href="" style="color: white;">Register</a>
<br> <br>
<p>The registration will apply only to the device you click this link on, <p>Use the link below to register for OwlBoard (Staff Version)</p>
you can use the same email address to register on other devices but you will <br>
need a separate registration link. <a href="https://owlboard.info/reg/auto.html?>>ACCESSCODE<<" style="color: azure; font-size: larger; background-color: #007979; padding: 8px; padding-left: 12px; padding-right: 12px; text-decoration: none; border-radius: 14px;">Register</a>
<br><br><br>
<p>Alternatively visit <a href="https://owlboard.info/reg">owlboard.info/reg</a> and paste in your access code:</p>
<p>>>ACCESSCODE<<</p>
<p>This registration is for one device only, you can register again using the
same email address for other devices and access OwlBoard from both.
</p>
<p>If you did not request to sign up to OwlBoard (Staff Version), you can
safely ignore this email.
</p> </p>
</td> </td>
</tr> </tr>
</table> </table>
<br>
</body> </body>
</html> </html>

View File

@ -0,0 +1,6 @@
Complete your OwlBoard (Staff) Registration using the link below.
https://owlboard.info/ref/auto.html?>>ACCESSCODE<<
Alternatively visit https://owlboard.info/ref/ and paste in your access code:
>>ACCESSCODE<<

View File

@ -7,24 +7,21 @@ const smtpUser = process.env.OWL_EML_USER
const smtpPass = process.env.OWL_EML_PASS const smtpPass = process.env.OWL_EML_PASS
const smtpHost = process.env.OWL_EML_HOST const smtpHost = process.env.OWL_EML_HOST
const smtpPort = process.env.OWL_EML_PORT const smtpPort = process.env.OWL_EML_PORT
// The 'secure' option is set to false as the SMTP server used only supports STARTTLS and will not accept TLS or no encryption
const options = { let transporter = mail.createTransport({
host: smtpHost, host: smtpHost,
port: smtpPort, port: smtpPort,
secure: false, secure: false, // Must be false for STARTTLS on port 587
auth: { auth: {
user: smtpUser, user: smtpUser,
pass: smtpPass pass: smtpPass
} }
} })
let transporter = mail.createTransport(options)
async function sendTest(to, cc, bcc) { async function sendTest(to, cc, bcc) {
log.out(`mailServices.sendTest: Sending test message to: ${to}`, "info") log.out(`mailServices.sendTest: Sending test message to: ${to}`, "info")
let tHtml = fs.readFile('mail-templates/test.html', 'utf-8'); let tHtml = fs.readFile('mail-templates/register.html', 'utf-8');
let tTxt = fs.readFile('mail-templates/test.txt', 'ascii') let tTxt = fs.readFile('mail-templates/register.txt', 'utf-8');
// Send test mail message // Send test mail message
try { try {
var res = await transporter.sendMail({ var res = await transporter.sendMail({
@ -33,8 +30,8 @@ async function sendTest(to, cc, bcc) {
cc: cc, cc: cc,
bcc: bcc, bcc: bcc,
subject: "Test Message from OwlBoard", subject: "Test Message from OwlBoard",
text: await tTxt, text: (await tTxt).replace(/>>ACCESSCODE<</g, "TEST-MESSAGE-ONLY"),
html: await tHtml html: (await tHtml).replace(/>>ACCESSCODE<</g, "TEST-MESSAGE-ONLY")
}); });
} catch(err) { } catch(err) {
log.out(err, "warn") log.out(err, "warn")
@ -43,8 +40,27 @@ async function sendTest(to, cc, bcc) {
return res; return res;
} }
async function sendRegister() { async function sendRegister(to, accesscode) {
return; log.out(`mailServices.sendRegister: Sending registration message to: ${to}`, "info")
let tHtml = fs.readFile('mail-templates/register.html', 'utf-8');
let tTxt = fs.readFile('mail-templates/register.txt', 'utf-8');
// Send test mail message
try {
var res = transporter.sendMail({
from: fromAdrr,
to: to,
cc: cc,
bcc: bcc,
subject: "OwlBoard - Complete Registration",
text: (await tTxt).replace(/>>ACCESSCODE<</g, accesscode),
html: (await tHtml).replace(/>>ACCESSCODE<</g, accesscode)
});
return await res;
} catch(err) {
log.out("mailServices.sendRegister: Mail send failed")
log.out(err, "warn")
return "failed"
}
} }
async function sendAlert() { async function sendAlert() {