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%;">
<head>
<title>OwlBoard - Register</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
html {
background-color: #2b343c;
background-color: #404c55;
background-image: radial-gradient(#2b343c,#404c55);
}
a {
color: white;
}
</style>
</head>
<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>
<td>
<img src="https://owlboard.info/images/logo/wide_logo.svg" style="height: 100px">
@ -17,15 +23,22 @@
<tr>
<td>
<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>
<p>The registration will apply only to the device you click this link on,
you can use the same email address to register on other devices but you will
need a separate registration link.
<p>Use the link below to register for OwlBoard (Staff Version)</p>
<br>
<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>
</td>
</tr>
</table>
<br>
</body>
</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 smtpHost = process.env.OWL_EML_HOST
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,
port: smtpPort,
secure: false,
secure: false, // Must be false for STARTTLS on port 587
auth: {
user: smtpUser,
pass: smtpPass
}
}
let transporter = mail.createTransport(options)
})
async function sendTest(to, cc, bcc) {
log.out(`mailServices.sendTest: Sending test message to: ${to}`, "info")
let tHtml = fs.readFile('mail-templates/test.html', 'utf-8');
let tTxt = fs.readFile('mail-templates/test.txt', 'ascii')
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 = await transporter.sendMail({
@ -33,8 +30,8 @@ async function sendTest(to, cc, bcc) {
cc: cc,
bcc: bcc,
subject: "Test Message from OwlBoard",
text: await tTxt,
html: await tHtml
text: (await tTxt).replace(/>>ACCESSCODE<</g, "TEST-MESSAGE-ONLY"),
html: (await tHtml).replace(/>>ACCESSCODE<</g, "TEST-MESSAGE-ONLY")
});
} catch(err) {
log.out(err, "warn")
@ -43,8 +40,27 @@ async function sendTest(to, cc, bcc) {
return res;
}
async function sendRegister() {
return;
async function sendRegister(to, accesscode) {
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() {