Skip to content

Commit

Permalink
Fix #25: Implement basic email sender
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Wilson committed Nov 14, 2019
1 parent fdda764 commit ac0b983
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"express-healthcheck": "^0.1.0",
"feedparser-promised": "^2.0.1",
"node-summarizer": "^1.0.7",
"nodemailer": "^6.3.1",
"sentiment": "^5.0.2"
},
"devDependencies": {
Expand Down
39 changes: 39 additions & 0 deletions src/email-sender.js
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);
}
});
};

0 comments on commit ac0b983

Please sign in to comment.