mirror of
https://github.com/nttgin/BGPalerter.git
synced 2024-05-19 06:50:08 +00:00
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
import Report from "./report";
|
|
import nodemailer from "nodemailer";
|
|
|
|
export default class ReportEmail extends Report {
|
|
|
|
constructor(channels, env) {
|
|
super(channels, env);
|
|
|
|
if (this.config.emailConfig.enabled) {
|
|
this.transporter = nodemailer.createTransport({
|
|
host: this.config.emailConfig.smtp,
|
|
port: this.config.emailConfig.port,
|
|
secure: this.config.emailConfig.secure,
|
|
auth: {
|
|
user: this.config.emailConfig.user,
|
|
pass: this.config.emailConfig.password
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
report = (message, content) => {
|
|
|
|
if (this.transporter) {
|
|
this.transporter
|
|
.sendMail({
|
|
from: this.config.emailConfig.email,
|
|
to: this.config.notifiedEmails.join(', '),
|
|
subject: "BGP alert: " + message,
|
|
text: "Hello world?"
|
|
})
|
|
.catch(error => {
|
|
this.logger.log({
|
|
level: 'error',
|
|
message: error
|
|
});
|
|
})
|
|
}
|
|
}
|
|
} |