· 9 years ago · Jun 30, 2017, 10:36 PM
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
17let 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
25transporter.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})
33res.end()
34 })
35
36export const send = () =>
37
38
39dispatch =>
40 axios.post('/api/nodemailer')
41 .then((res) => (console.log("did a thing!!!!", res.data)))
42 .catch(console.error())