-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #25: Implement basic email sender
- Loading branch information
Ryan Wilson
committed
Nov 14, 2019
1 parent
fdda764
commit ac0b983
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const 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 (errorMessage) { | ||
// Recipients list of users to send the email too | ||
// receipiants is commas separated (emailName@hotmail.com,emailName2@hotmail.com) | ||
const receipiants = ''; | ||
|
||
// Credientials to send an email from | ||
const 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: ${errorMessage} </p>`, // Message Body | ||
}; | ||
|
||
// Send the email with the email content | ||
transporter.sendMail(mailOptions, (err, info) => { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log(info); | ||
} | ||
}); | ||
}; |