-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteamMailer.js
More file actions
39 lines (37 loc) · 1.07 KB
/
Copy pathteamMailer.js
File metadata and controls
39 lines (37 loc) · 1.07 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
const nodemailer = require('nodemailer2'),
hbs = require('nodemailer-express-handlebars')
module.exports.sendTeamMail = (user, callback) => {
let auth = {
user: 'manthandisha18@gmail.com',
pass: process.env.UserPassword
}
console.log(auth)
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: auth
})
let mailOptions = {
from: '"Manthan 2018" ' + auth.user,
to: 'shuhulkaul22@gmail.com',
subject: 'New Kurukshetra Registration',
template: 'teammail',
context: {
user: user
}
}
let options = {
viewEngine: {
extname: 'handlebars',
layoutsDir: './views/mails'
},
viewPath: './views/mails'
}
transporter.use('compile', hbs(options))
transporter
.sendMail(mailOptions, (err, info) => {
if (err) return console.log(err)
console.log('mail sent to ' + user.email, info.messageId, info.response)
console.log(info)
callback(err)
})
}