-
In user.js file I am saving data and fetching data as per requirement. Now I am sending mail to the user when he registered. In user.js I call the follwoing function :-
user.js File var emailFunction = require('.././email-functions-html/emailsFunctions'); emailFunction.send_pass_social_user(my_user_data);
-
** This is the email file which I called to send my mail.
emailUtil.js
var nodemailer = require('nodemailer');
// Not the movie transporter! var transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: 'mail', // Your email id pass: 'pass' // Your password } });
sendEmail: function sendMail(varhtml,vartext, varsubject,varfrom, varfrom_name,varto, varto_name, reply_to_email ) {
//setup e-mail data with unicode symbols list of receivers to: [varto], // list of receivers subject: varsubject, // Subject line text: vartext, // plaintext body html: varhtml // html body }; console.log(mailOptions); // send mail with defined transport object transporter.sendMail(mailOptions, function (error, info) { if (error) { return console.log(error); }else{ return console.log(info); } });
}
}
-
// In this file, I created multiple functions for multiple HTML files and for multiple data.
emailsFunctions.js file var emailUtil = require("../routes/emailUtil.js"); var config = require("../routes/config.json"); var emailsFunction = { send_pass_social_user : function(user_data){ emailUtil.sendEmail(emailBody, "emailHTML", emailSubject, "", "", 'listOfUsers',"Subject",""); } } module.exports = emailsFunction;
Firstly I want to pass variable to my HTML file and then want that hTMl content send to emailUtil Function so that I can render my HTML page with dynamic user_data in mail. I heard about jade and other npm modules for doing this. But if get some examples it would be very helpful for me. Please let me know if there is any concern about the question. In advance, thanks for the help.
via VIKAS KOHLI
No comments:
Post a Comment