mirror of
https://github.com/KevinMidboe/ISPDowntimeMonitor.git
synced 2025-10-29 17:50:12 +00:00
Scrape, navigate and print ISP's status page for a given address. This only works with telenor and the URL must be a search for a given address. If any services are found to be down a mail is sent from and to accounts set in config.js.
41 lines
968 B
JavaScript
41 lines
968 B
JavaScript
const nodemailer = require( 'nodemailer')
|
|
const config = require('../config.js')
|
|
|
|
class Mail {
|
|
constructor(sender=undefined, password=undefined, recipient=undefined) {
|
|
this.sender = sender || config.senderEmail;
|
|
this.password = password || config.senderPassword;
|
|
this.recipient = recipient || config.recipientEmail;
|
|
this.transporter = this.setupTransporter();
|
|
}
|
|
|
|
setupTransporter() {
|
|
return nodemailer.createTransport({
|
|
service: 'gmail',
|
|
auth: {
|
|
user: this.sender,
|
|
pass: this.password
|
|
}
|
|
})
|
|
}
|
|
|
|
sendMail = message => this.transporter.sendMail(message);
|
|
|
|
sendAttachment = fileRef => {
|
|
const message = {
|
|
from: `"Fred Foo 👻" <${this.sender}>`,
|
|
to: this.recipient,
|
|
subject: 'Telenor nedetid',
|
|
text: "hello wordl",
|
|
html: "<p>hello wordl</p>",
|
|
attachments: [{
|
|
path: fileRef
|
|
}]
|
|
}
|
|
|
|
return this.sendMail(message)
|
|
}
|
|
}
|
|
|
|
module.exports = Mail
|