-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailer.js
52 lines (50 loc) · 1.55 KB
/
mailer.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
const nodemailer = require('nodemailer')
const Email = require('email-templates')
const config = require('./config')
let EmailTemplate = require('email-templates').EmailTemplate
function initMailer() {
let transporterConf = {
name: config.emailer.hostname,
host: config.emailer.smtp_host,
port: config.emailer.smtp_port,
secure: true,
auth: {
user: config.emailer.username,
pass: config.emailer.password
},
tls:{
ciphers:'SSLv3'
}
}
return {
sendVerificationMail(address, username, name, tokenUrl) {
const email = new Email({
message: {
from: `${config.emailer.sender_fullname} <${transporterConf.auth.user}>`,
subject: 'SOSKE | Email Confirmation'
},
send: true,
transport: nodemailer.createTransport(transporterConf),
views: {
options: {
extension: 'ejs'
}
}
});
email.send(
{
template: 'verifyEmail',
message: { to: address },
locals: {
name: name,
username: username,
email: address,
token: tokenUrl
}
}
).catch (console.error)
.then(console.log)
}
}
}
module.exports = initMailer