-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsendMail.js
More file actions
52 lines (47 loc) · 1.53 KB
/
Copy pathsendMail.js
File metadata and controls
52 lines (47 loc) · 1.53 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
45
46
47
48
49
50
51
52
var debug = require('debug')('SendMail:SendMail');
var nodemailer = require('nodemailer');
function sendMail(ToAddress, Subject, replyTo, htmlData, mailConfig, callback) {
debug("sendMail", ToAddress);
// if (ToAddress == undefined || ToAddress.length < 10) {
// ToAddress = 'darshit@byteprophecy.com';
// }
var transport = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: mailConfig.Mailusername,
pass: mailConfig.Mailpassword
}
});
var mailOptions = {
from: mailConfig.FromAddress,
to: ToAddress,
subject: Subject,
replyTo: (replyTo == null || replyTo == undefined ? mailConfig.Mailusername : replyTo.toString() + " <" + mailConfig.Mailusername.toString() + ">"),
//inReplyTo: (replyTo == null || replyTo == undefined ? mailConfig.Mailusername : ''),
//text: "Hello world", // plaintext body
html: htmlData // html body
}
try {
transport.sendMail(mailOptions, function(err, responseStatus) {
if (err) {
callback({
status: false,
error: err
});
} else {
callback({
status: true,
data: responseStatus
});
}
});
} catch (ex) {
callback({
status: false,
error: ex
});
}
}
module.exports = {
sendMail: sendMail
}