forked from siddharthvp/SDZeroBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
email.ts
26 lines (22 loc) · 796 Bytes
/
email.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import * as nodemailer from 'nodemailer';
import {logFullError} from "./botbase";
/**
* Module for sending email, since /usr/sbin/exim or /usr/bin/mail
* are not available within the Toolforge Kubernetes cluster
*/
const transporter = nodemailer.createTransport({
host: 'mail.tools.wmflabs.org',
port: 465,
});
export async function sendMail(subject: string, body: string) {
return transporter.sendMail({
from: '[email protected]',
to: '[email protected]',
subject: subject,
html: body,
});
}
export async function emailOnError(err: Error, taskname: string, isFatal: boolean) {
logFullError(err, isFatal);
sendMail(`${taskname} error`, `n${taskname} task resulted in the error:\n\n${err.stack}\n`);
}