-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail-send.js
55 lines (48 loc) · 1.04 KB
/
mail-send.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
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
*
Mailbox configuration
* */
const gMmailboxConfig={
host: 'mail.mail.it',
port: 587,
tls: {
ciphers:'SSLv3',
rejectUnauthorized: false
},
debug:true,
auth: {
user: 'mail@mail.it',
pass: 'password'
}
};
/**
* send a mail
* @param recipient list comma separated email address recipients
* @param subject
* @param text
* @param htmlText text with html formatting
* */
module.exports.sendMail = function(recipient, subject, text, htmlText = ""){
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport(gMmailboxConfig);
transporter.verify(function(error, success) {
if (error)
console.log(error);
else
{
var mailOptions = {
from: '"Mail" <mail@mail.it>', // sender address
to: recipient, // list of receivers
subject: subject, // Subject line
html: htmlText, // html body
text: text
};
transporter.sendMail(mailOptions, function(error, info){
if(error)
console.log(error);
else
console.log('Message sent: ' + info.response);
});
}
});
}