Send status e-mail

This commit is contained in:
Romein van Buren 2022-08-06 19:14:20 +02:00
parent e973d4dfea
commit 6f32a9eb3b
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49

View File

@ -56,16 +56,26 @@ async function processOutage({ outage, server, settings, onDateUpdated }) {
// Send e-mail notification // Send e-mail notification
if (server.sendEmail && settings.emailSender && settings.emailRecipient) { if (server.sendEmail && settings.emailSender && settings.emailRecipient) {
try { try {
server.sendEmail({ const date = new Date().toLocaleString('en-GB', {
dateStyle: 'full',
timeStyle: 'full',
timeZone: 'Etc/UTC',
});
const a = await server.sendEmail({
sender: settings.emailSender, sender: settings.emailSender,
to: settings.emailRecipient, to: settings.emailRecipient,
subject: `[outage] ${service.name} is down`, subject: `[outage] ${service.name} is down`,
body: `<p>Dear recipient,</p> body: `Dear recipient,
<p>This is to inform you about web service outage.
The service <em>${service.name}</em> does not meet the As of ${date} UTC time, the service "${service.name}" does not meet the requirements for being
requirements for being considered as 'working'.</p> considered as working.
<p>Please always check this before taking action.</p>`,
Technical information containing the reason for this alert:
${JSON.stringify(testResult, null, 2)}
Please always check this before taking action. This is an automated message.`,
}); });
console.log(a);
} }
catch (err) { catch (err) {
server.error('could not send endpoint status notification e-mail'); server.error('could not send endpoint status notification e-mail');