sendEmail.js 6.38 KB

import nodemailer from "nodemailer";

export default function (req, res) {
//   let nodemailer = require("nodemailer");
  const transporter = nodemailer.createTransport({
    port: 465,
    host: "smtp.gmail.com",
    auth: {
      user: "dheeraj.realatte@gmail.com",
      pass: "pamoocbnzfqhigdf",
    },
    secure: true,
  });
  var maillist = ["sujatalogicloop@gmail.com"];
  const mailData = {
    from: ["sujatalogicloop@gmail.com"],
    to: maillist,
    subject: `Advith Consulting Contact Form Leads`,
    html: `
          <table border="0" cellpadding="0" cellspacing="0" style="padding-top:35px; background-color:#f1f1f1; font-family:Verdana,Arial,sans-serif; color:#454748; width:100%; border-collapse:separate;">
              <tbody>
              <tr>
                  <td align="center">
                      <table border="0" cellpadding="0" cellspacing="0" width="590" style="padding:16px; background-color:white; color:#454748; border-collapse:separate;">
                          <tbody>
                          <tr>
                              <td align="center" style="min-width:590px;">
                                  <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width:590px; background-color:white; padding:0px 8px 0px 8px; border-collapse:separate;">
                                      <tbody>
                                      <tr>
                                          <td valign="middle">
                                              <strong style="font-size:16px; margin: 0;">Welcome to Advith Consulting</strong>
                                          
                                          </td>
                                      </tr>
                                      <tr>
                                          <td colspan="2" style="text-align:center;">
                                              <hr width="100%" style="border-top-color:rgba(0,0,0,0.1); border-top-style:solid; border-top-width:1px; border-left-width:0px; border-bottom-width:0px; border-right-width:0px; overflow-y:visible; overflow-x:visible; height:0px; box-sizing:content-box; background-color:rgb(204,204,204); border:medium none; clear:both; display:block; font-size:0px; min-height:1px; line-height:0; margin:16px 0px 16px 0px;">
                                          </td>
                                      </tr>
                                      </tbody>
                                  </table>
                              </td>
                          </tr>
                          <tr>
                              <td align="center" style="min-width:590px;">
                                  <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width:590px; background-color:white; padding:0px 8px 0px 8px; border-collapse:separate;">
                                      <tbody>
                                      <tr>
                                          <td colspan="2" valign="top" style="font-size:13px;">
                                              <div style="font-size:13px; font-family:&quotLucida Grande&quot,Helvetica,Verdana,Arial,sans-serif;">
                                                      Details below are enquiry from website!<br><br>
              
                                              </div>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td valign="top" style="font-size:13px;">
                                              <div style="font-size:13px; font-family:&quotLucida Grande&quot,Helvetica,Verdana,Arial,sans-serif;">
                                                  <tr><td colspan="2"><b>Personal Details:</b></td></tr>
                                                  <tr><td style="width: 30%;">Name:</td><td style="width: 70%;">${req.body.Name}</td></tr>
                                                  <tr><td style="width: 30%;">Email:</td><td style="width: 70%;">${req.body.Email}</td></tr>
                                                  <tr><td style="width: 30%;">Mobile:</td><td style="width: 70%;">${req.body.Mobile}</td></tr>
                                                  <tr><td style="width: 30%;">Company:</td><td style="width: 70%;">${req.body.Company}</td></tr>
                                                  <tr><td style="width: 30%;">Message:</td><td style="width: 70%;">${req.body.AdditionalMessage }</td></tr>
                                              <br><br>
                                              </div>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td colspan="2" style="text-align:center;">
                                              <hr width="100%" style="border-top-color:rgba(0,0,0,0.1); border-top-style:solid; border-top-width:1px; border-left-width:0px; border-bottom-width:0px; border-right-width:0px; overflow-y:visible; overflow-x:visible; height:0px; box-sizing:content-box; background-color:rgb(204,204,204); border:medium none; clear:both; display:block; font-size:0px; min-height:1px; line-height:0; margin:16px 0px 16px 0px;">
                                          </td>
                                      </tr>
                                      </tbody>
                                  </table>
                              </td>
                          </tr>
          
                         
                          </tbody>
                      </table>
                  </td>
              </tr>
              <tr>
                  <td align="center" style="min-width:590px;">
                      <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width:590px; background-color:#f1f1f1; color:#454748; padding:8px; border-collapse:separate;">
                          <tbody>
                          <tr>
                              <td style="text-align:center; font-size:13px;"><br></td>
                          </tr>
                          </tbody>
                      </table>
                  </td>
              </tr>
              </tbody>
          </table>`,
  };
  transporter.sendMail(mailData, function (err, info) {
    if (err) console.log(err);
    else console.log(info);
  });
  console.log(req.body);
  res.send("success");
}