Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. 'use strict'
  2. const nodemailer = require('nodemailer')
  3. // need to add FindUser in case user exists
  4. module.exports = require('express').Router()
  5. .post('/', (req, res, next) =>{
  6. // create reusable transporter object using the default SMTP transport
  7. let transporter = nodemailer.createTransport({
  8. host: 'localhost',
  9. port: 1337,
  10. secure: true, // secure:true for port 465, secure:false for port 587
  11. auth: {
  12. user: '*****@gmail.com',
  13. pass: '****'
  14. }
  15. })
  16. // setup email data with unicode symbols
  17. let mailOptions = {
  18. from: '"Fred Foo 👻" <******@gmail.com>', // sender address
  19. to: '******@gmail.com', // list of receivers
  20. subject: 'Hello ✔', // Subject line
  21. text: 'Hello world ?', // plain text body
  22. html: '<b>Hello world ?</b>' // html body
  23. }
  24. // send mail with defined transport object
  25. transporter.sendMail(mailOptions, (error, info) => {
  26. if (error) {
  27. return console.log(error);
  28. }
  29. console.log('Message %s sent: %s', info.messageId, info.response);
  30. transporter.close()
  31. req.end()
  32. })
  33. res.end()
  34. })
  35.  
  36. export const send = () =>
  37.  
  38.  
  39. dispatch =>
  40. axios.post('/api/nodemailer')
  41. .then((res) => (console.log("did a thing!!!!", res.data)))
  42. .catch(console.error())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement