tracman-server/config/mail.js

41 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-04-01 11:03:31 -06:00
'use strict';
const nodemailer = require('nodemailer'),
2017-04-26 21:13:14 -06:00
env = require('./env/env.js');
2017-04-10 01:00:56 -06:00
let transporter = nodemailer.createTransport({
2017-05-30 12:33:41 -06:00
host: env.mailserver,
port: env.mailport,
2017-04-01 11:03:31 -06:00
secure: false,
requireTLS: true,
2017-05-30 12:33:41 -06:00
auth: env.mailauth,
// logger: true,
// debug: true
2017-04-10 01:00:56 -06:00
});
module.exports = {
2017-05-30 12:30:09 -06:00
verify: ()=>{
transporter.verify( (err,success)=>{
if (err){ console.error(`SMTP Error: ${err}`); }
2017-05-30 12:39:24 -06:00
console.log(`📧 SMTP ${!success?'not ':''}ready`);
2017-05-30 12:30:09 -06:00
} );
},
send: transporter.sendMail.bind(transporter),
text: (text)=>{
return `Tracman\n\n${text}\n\nDo not reply to this email\nFor information about why you received this email, see the privacy policy at ${env.url}/privacyy#email`;
},
html: (text)=>{
return `<h1><a href="/" style="text-decoration:none;"><span style="color:#000;font-family:sans-serif;font-size:36px;font-weight:bold"><img src="${env.url}/static/img/icon/by/32.png" alt="+" style="margin-right:10px">Tracman</span></a></h1>${text}<p style="font-size:8px;">Do not reply to this email. For information about why you recieved this email, see our <a href="${env.url}/privacy#email">privacy policy</a>. </p>`;
},
2017-05-08 15:45:06 -06:00
noReply: `"Tracman" <NoReply@tracman.org>`,
to: (user)=>{
return `"${user.name}" <${user.email}>`;
}
};