forked from Seneca-CDOT/telescope
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryan Wilson
committed
Nov 12, 2019
1 parent
f9874cb
commit 0f0fe08
Showing
1 changed file
with
31 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
var nodemailer = require('nodemailer'); | ||
let nodemailer = require('nodemailer'); | ||
|
||
/************************************************************************* | ||
/************************************************************************* | ||
* HOW TO USE * | ||
* Import this file - const sendEmail = require('./email-sender); * | ||
* send email - sendEmail.sendMessage("Put your error message in here"); * | ||
**************************************************************************/ | ||
|
||
exports.sendMessage = async function (err) { | ||
exports.sendMessage = async function (errorMessage) { | ||
|
||
//Recipients list of users to send the email too | ||
//receipiants is commas separated (emailName@hotmail.com,emailName2@hotmail.com) | ||
var receipiants = ''; | ||
// Recipients list of users to send the email too | ||
// receipiants is commas separated (emailName@hotmail.com,emailName2@hotmail.com) | ||
var receipiants = ''; | ||
|
||
//Credientials to send an email from | ||
var transporter = nodemailer.createTransport({ | ||
service: 'gmail', | ||
auth: { | ||
user: '', // Email Name (.env variables must be used refer to issue#60) | ||
pass: '' //Email Pass (.env variables must be used refer to issue#60) | ||
} | ||
}); | ||
// Credientials to send an email from | ||
var transporter = nodemailer.createTransport({ | ||
service: 'gmail', | ||
auth: { | ||
user: '', // Email Name (.env variables must be used refer to issue#60) | ||
pass: '' // Email Pass (.env variables must be used refer to issue#60) | ||
}, | ||
}); | ||
|
||
//Email Content | ||
const mailOptions = { | ||
from: '', //Email Name | ||
to: receipiants, | ||
subject: 'Seneca Telescope had an error', //Subject Line | ||
html: '<p>An Error has occurred <br/>Error Message:' + err + '</p>' //Message Body | ||
}; | ||
// Email Content | ||
const mailOptions = { | ||
from: '', // Email Name | ||
to: receipiants, | ||
subject: 'Seneca Telescope had an error', // Subject Line | ||
html: '<p>An Error has occurred <br/>Error Message:' + errorMessage + '</p>', // Message Body | ||
}; | ||
|
||
//Send the email with the email content | ||
transporter.sendMail(mailOptions, function (err, info) { | ||
if (err) | ||
console.log(err); | ||
else | ||
console.log(info); | ||
}); | ||
} | ||
// Send the email with the email content | ||
transporter.sendMail(mailOptions, function (err, info) { | ||
if (err) { | ||
console.log(err); | ||
} | ||
else { | ||
console.log(info); | ||
} | ||
}); | ||
}; |