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
if (server.sendEmail && settings.emailSender && settings.emailRecipient) {
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,
to: settings.emailRecipient,
subject: `[outage] ${service.name} is down`,
body: `<p>Dear recipient,</p>
<p>This is to inform you about web service outage.
The service <em>${service.name}</em> does not meet the
requirements for being considered as 'working'.</p>
<p>Please always check this before taking action.</p>`,
body: `Dear recipient,
As of ${date} UTC time, the service "${service.name}" does not meet the requirements for being
considered as working.
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) {
server.error('could not send endpoint status notification e-mail');