-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailer.js
40 lines (36 loc) · 933 Bytes
/
mailer.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 express = require("express"); // call express
const app = express();
const nodemailer = require("nodemailer");
const attachments = [
{
filename: "as.docx",
path: "/home/sonu/Desktop/as.docx",
contentType: "application/document",
},
];
var transporter = nodemailer.createTransport({
service: "gmail",
auth: {
user: "xxxxxxx@gmail.com",
pass: "xxxxxxxx",
},
});
var mailOptions = {
from: "xxxxxxx@gmail.com",
to: "xxxxxxxxxx@gmail.com",
subject: "Sending Email using Node.js",
text: "That was easy!",
attachments: attachments,
};
transporter.sendMail(mailOptions, function(error, info) {
if (error) {
console.log(error);
} else {
console.log("Email sent: " + info.response);
}
});
var server = app.listen(8080, function() {
var host = server.address().address;
var port = server.address().port;
console.log("Example app listening at http://%s:%s", host, port);
});