first version

parent 3f6e73c4
'use strict';
const nodemailer = require("nodemailer");
const smtpTransport = require("nodemailer-smtp-transport");
const htmlToText = require('html-to-text');
module.exports = function (host, port, user, password, from, signature) {
let transport = nodemailer.createTransport(smtpTransport({
host: host,
port: port,
auth: {
user: user,
pass: password
}
}));
return {
sendHtml : function (mail, subject, html) {
html += signature;
return this.sendHtmlWithoutSignature(mail, subject, html);
},
sendHtmlWithoutSignature : function (mail, subject, html) {
return new Promise((success, reject) => {
transport.sendMail({
from: from,
to: mail,
subject: subject,
text : htmlToText.fromString(html, {wordwrap: 130}),
html: html
}, function(error, response) {
if (error) {
reject(error);
} else {
success(response);
}
});
});
}
}
};
\ No newline at end of file
{
"name": "mailer",
"version": "1.0.0",
"description": "Mailer for mirera and piktomir web servers",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://git.niisi.ru/mirera/mailer.git"
},
"keywords": [
"mail"
],
"dependencies": {
"html-to-text": "^2.1.3",
"nodemailer": "^2.6.0",
"nodemailer-smtp-transport": "^2.7.2"
},
"author": "Danila Eremin",
"license": "MIT"
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment