-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendmail.js
68 lines (47 loc) · 1.63 KB
/
sendmail.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'use strict'
const Router = require('express').Router()
const nodemailer = require('nodemailer')
// const transport = {
// name: 'localhost:1337' // must be the same that can be reverse resolved by DNS for your IP
// };
const transport = {
host: 'smtp.gmail.com',
port: 465,
secure: true, // use SSL
auth: {
user: '[email protected]',
pass: 'Fullst@ck'
}
};
const transporter = nodemailer.createTransport(transport);
Router.post('/', function(req,res,next){
// console.log(req.body.products[0].artistName)
var productString = '';
for (let i=0; i<req.body.products.length; i++){
tempString += `<div> ${req.body.products[i].artistName} </div>` +
`<div> ${req.body.products[i].giveImage} </div>`
}
var introString = '<h1> Thank you for your purchase! </h1> <p> You have the following purchases: </p>'
var emailString = introString + productString
const mailOptions = {
from: '[email protected]',
to: req.body.email,
subject: 'DJ KM Order ' + req.body.orderNumber,
// text: 'haye',
html: emailString
};
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
})
// var mailOptions = {
// from: '"Fred Foo 👥" <[email protected]>', // sender address
// to: '[email protected], [email protected]', // list of receivers
// subject: 'Hello ✔', // Subject line
// text: 'Hello world 🐴', // plaintext body
// html: '<b>Hello world 🐴</b>' // html body
// };
module.exports = Router;