-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendEmail.js
More file actions
42 lines (36 loc) · 1.23 KB
/
Copy pathsendEmail.js
File metadata and controls
42 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*jshint esversion: 6 */
/*jslint node: true */
'use strict';
// import modules
const nodemailer = require('nodemailer');
// set global variables
const GU = process.env.GU;
const GK = process.env.GK;
// create sendEmail function
const sendEmail = function () {
// create reusable transporter object with SMTP
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: GU,
pass: GK
}
});
// create email
let mailOptions = {
from: 'Melvin Gruesbeck<mgruesbeck@gmail.com>', // sender
to: 'mgruesbeck@gmail.com', // receivers
subject: 'Yo yo yo! There is a new boat to row!', // subject
text: 'See the latest: https://sfbay.craigslist.org/search/boa?sort=date&query=sunfish.', // text body
html: '<p>See the latest: </p><a href="https://sfbay.craigslist.org/search/boa?sort=date&query=sunfish">https://sfbay.craigslist.org/search/boa?sort=date&query=sunfish</a>.' // html body
};
// send email
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
});
};
// export sendEmail function
module.exports = sendEmail;