forked from novuhq/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (37 loc) · 970 Bytes
/
index.js
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
const nodemailer = require("nodemailer")
const nodemailerTransporter = nodemailer.createTransport({
service: "gmail",
auth: {
user: "<[email protected]>",
pass: "<generated_app_password>"
}
})
const mailDetails = {
from: '<[email protected]>',
to: '<[email protected]>',
subject: 'Test mail',
html: `<h2>Happy birthday bor</h2>
<p style="color: red">Great minds meet!</p>
<button>Thank you</button>
`,
attachments: [
{
filename: "School.jpg",
path: "./stock.jpg"
},
{
path: "./sweet.jpg"
},
{
filename: "testing.txt",
content: "I am just testing out this docs"
}
]
};
nodemailerTransporter.sendMail(mailDetails, function(err, data) {
if(err) {
console.log('Error Occurs!', err);
} else {
console.log('Email sent successfully');
}
});