-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail.js
More file actions
44 lines (37 loc) · 1.51 KB
/
mail.js
File metadata and controls
44 lines (37 loc) · 1.51 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
43
44
'use strict';
// require('dotenv').config();
const nodemailer = require('nodemailer');
// Generate test SMTP service account from ethereal.email
// Only needed if you don't have a real mail account for testing
nodemailer.createTestAccount((err, account) => {
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
service: "Gmail",
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: "workload.cs17@gmail.com", // generated ethereal user
pass: "Workload12345" , // generated ethereal password
}
});
// setup email data with unicode symbols
let mailOptions = {
from: '"Hamza Nasim"<workLoad@gmail.com>', // sender address
to: 'm103462@nwytg.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world?', // plain text body
html: '<b>Hello world?</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message sent: %s', info.messageId);
// Preview only available when sending through an Ethereal account
console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
// Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
});
});