Advertisement
Guest User

send

a guest
Jan 21st, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var express = require('express');
  2. var app = express();
  3. app.use(bodyParser.urlencoded({ extended: false }));
  4. app.use(bodyParser.json());
  5. var nodemailer = require("nodemailer");
  6. app.post('/send',(req,ress)=>{
  7.   //  const {name , company , email , phone , message} = req.body;
  8.     let transporter = nodemailer.createTransport({
  9.         host: "mail.ewstudio.tech",
  10.         port: 465,
  11.         secure: true, // true for 465, false for other ports
  12.         auth: {
  13.           user: "testnode@ewstudio.tech", // generated ethereal user
  14.           pass: "G12H(!CHON=9" // generated ethereal password
  15.         },
  16.         tls:{
  17.             rejectUnathorized:false
  18.         }
  19.     });
  20.    
  21.     const body=''
  22.       // setup email data with unicode symbols
  23.     let mailOptions = {
  24.         from: '"Test Node" <testnode@ewstudio.tech>', // sender address
  25.         to: "ganar.gatul@gmail.com", // list of receivers
  26.         subject: "Hai Express ✔", // Subject line
  27.         text: "Hello Dev", // plain text body
  28.         html: htmlbody // html body
  29.     };
  30.    
  31.     transporter.sendMail(mailOptions,(err,info)=>{
  32.         if(err){
  33.             console.log("ERROR MAIL!");
  34.         }
  35.         console.log("Message sent: %s", info.messageId);
  36.         // Preview only available when sending through an Ethereal account
  37.         console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
  38.     })
  39.    
  40.     ress.json({"Message":"Auth Code Has Been Send"})
  41.    
  42. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement