Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const nodemailer = require('nodemailer');
- let port = process.env.PORT || 3000;
- let transporter = nodemailer.createTransport({
- service: 'gmail',
- secure: false,
- port: 25,
- auth:{
- user: 'myownemail@gmail.com',
- pass: '**************'
- }
- })
- let mailOptions = {
- from: '"Portfolio Message" <myotheremail@gmail.com> ',
- to: 'myownemail@gmail.com',
- subject: '',
- text: '',
- html: ''
- }
- app.post('/message/new',function(req,res){
- res.writeHead(200, { 'Content-Type': 'application/json' });
- res.write(JSON.stringify({ status: "OK" }));
- res.end();
- mailOptions['subject'] = 'new portfolio message from ' + req.body.name ;
- mailOptions['text'] = req.body.message + " n " + " phone number or email : " + req.body.phone_or_email;
- transporter.sendMail(mailOptions,(error,info)=>{
- error?console.log('error',error):console.log('success');
- });
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement