Advertisement
Guest User

Untitled

a guest
Jun 12th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. const nodemailer = require('nodemailer')
  2. const config = require('./config')
  3.  
  4. // create reusable transporter object using the default SMTP transport
  5. var transporter = nodemailer.createTransport("SMTP", {
  6. service: "Gmail",
  7. auth: {
  8. user: config.mailUser,
  9. pass: config.mailPass
  10. }
  11. });
  12.  
  13. module.exports = function (app) {
  14. // send mail with defined transport object
  15. app.post('/send', function(req, res){
  16. // setup e-mail data with unicode symbols
  17. var mailOptions = {
  18. from: ''+config.mailUser+'', // sender address
  19. to: req.body.receivers, // list of receivers
  20. subject: req.body.subject, // Subject line
  21. text: req.body.text, // plaintext body
  22. // html: '<b>Hello world 🐴</b>' // html body
  23. };
  24. transporter.sendMail(mailOptions, function(error, info){
  25. if(error){
  26. return res.send(error);
  27. }
  28. return res.send("mail send successfully");
  29. });
  30. })
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement