mirror of
https://gitlab.com/nekoya/web.git
synced 2024-11-25 07:47:02 +01:00
Add send Mail module
This commit is contained in:
parent
9a81da7a3b
commit
26a7201d72
1 changed files with 43 additions and 0 deletions
43
modules/mail.js
Normal file
43
modules/mail.js
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
var nodemailer = require("nodemailer");
|
||||||
|
|
||||||
|
let config;
|
||||||
|
try {
|
||||||
|
config = require('../config');
|
||||||
|
} catch (e) {
|
||||||
|
console.log('No config file found');
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function send(email, token) {
|
||||||
|
var email = email;
|
||||||
|
var token = token;
|
||||||
|
var mail = nodemailer.createTransport({
|
||||||
|
host: config.mail.host,
|
||||||
|
port: config.mail.port,
|
||||||
|
secure: false,
|
||||||
|
auth: {
|
||||||
|
user: config.mail.user,
|
||||||
|
pass: config.mail.password,
|
||||||
|
},
|
||||||
|
tls: {
|
||||||
|
rejectUnauthorized: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
var mailOptions = {
|
||||||
|
from: config.mail.user,
|
||||||
|
to: email,
|
||||||
|
subject: "Account Verification - Nekoya",
|
||||||
|
html: `<p>Hello!!! Please click this link <a href="${config.host}/verify-email?token=${token}">link</a> to verify your account!!! Thanks!!!</p>`
|
||||||
|
};
|
||||||
|
mail.sendMail(mailOptions, function (error, info) {
|
||||||
|
if (error) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
send
|
||||||
|
}
|
Loading…
Reference in a new issue