Repository navigation
Expand file tree
/
Copy pathsendmail.js
More file actions
64 lines (52 loc) · 1.69 KB
/
Copy pathsendmail.js
File metadata and controls
64 lines (52 loc) · 1.69 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
53
54
55
56
57
58
59
60
61
62
63
64
var nodemailer = require('nodemailer');
var hbs = require('nodemailer-express-handlebars');
function sendMail (transaction_id, side, params={}) {
console.log("oneway*****")
//var template = (side==='oneway')?"email-close-opportunity-template-oneway.hbs": "email-close-opportunity-template.hbs"
var options = {
viewEngine: {
extname: '.hbs',
layoutsDir: 'email/',
defaultLayout : 'template'
},
viewPath: 'email/',
extName: '.hbs'
};
var mailer = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'sqv.team@gmail.com',
pass: 'smettoquandovoglio.1'
},
logger: true,
debug: false
});
mailer.use('compile', hbs(options));
if (side==='oneway') {
console.log("oneway")
mailer.sendMail({
from: 'SQV Team',
to: 'andrea.franco@gmail.com, piergiorgio.ret@libero.it, dangelo.giovanni@gmail.com, andrea.manno83@gmail.com, leonardo979@gmail.com',
cc: 'sqv.team@gmail.com',
subject: 'Oppurtinity ID: '+ transaction_id + ' closed',
template: 'oneway_body',
context: params
}, function (error, response) {
console.log('mail sent to SQV');
mailer.close();
});
} else {
mailer.sendMail({
from: 'SQV Team',
to: 'andrea.franco@gmail.com, piergiorgio.ret@libero.it, dangelo.giovanni@gmail.com, andrea.manno83@gmail.com, leonardo979@gmail.com',
cc: 'sqv.team@gmail.com',
subject: 'Oppurtinity ID: '+ transaction_id + ' closed',
template: 'roundtrip_body',
context: params
}, function (error, response) {
console.log('mail sent to ' + to);
mailer.close();
});
}
}
exports.sendMail=sendMail