Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var nodemailer = require("nodemailer"),
- q = require("q"),
- config = require("../config.js"),
- transporter = nodemailer.createTransport({
- host: config.host,
- port: 587,
- secure: config.secure, // true for 465, false for other ports
- auth: {
- user: config.user, // generated ethereal user
- pass: config.password // generated ethereal password
- }
- });
- /**
- * @description get data and mail details and send from mail to target mail
- * @param {string} from mail address
- * @param {string} to mail address
- * @param {string} subject mail subject
- * @param {string} text title of mail
- * @param {string} html html code as string or other content should be sent
- */
- function send(from, to, subject, text, html) {
- var deferred = q.defer(),
- message = {
- from: from || config.user, // sender address
- to: to, // list of receivers
- subject: subject, // Subject line
- text: text || 'Team', // plain text body
- html: html // html body
- };
- transporter.sendMail(message, function (error, info) {
- if (error) {
- deferred.reject({
- error: error
- });
- } else {
- deferred.resolve({
- success: info
- });
- }
- });
- return deferred.promise;
- }
- export
- s.send = send;
Add Comment
Please, Sign In to add comment