Localhost works fine, but issue come Zoha mailer on live server

Localhost works fine, but issue come Zoha mailer on live server

  1. package.json

  2.       "proxy": {
  3.         "/auth/google": {
  4.           "target": "http://localhost:8000/"
  5.         }
  6.       },
ContactForm.jsx

  1. import React, { useState, useEffect } from 'react'

  2. const ContactForm = () => {

  3.     const [fname, setFname] = useState("");
  4.     const [lname, setLname] = useState("");
  5.     const [email, setEmail] = useState("");
  6.     const [subject, setSubject] = useState("");
  7.     const [msg, setMsg] = useState("");
  8.     const [message, setMessage] = useState('');

  9.     useEffect(() => {
  10.         setTimeout(function () {
  11.             setMessage(true)
  12.         }, 9000);
  13.     },
  14.         [message])


  15.     const sendEmail = async (e) => {
  16.         e.preventDefault();


  17.         setFname("");
  18.         setLname("");
  19.         setEmail("");
  20.         setSubject("");
  21.         setMsg("");

  22.         setMessage(`Thank you ${fname} ${lname} for enquiry. We will back to you asap.`);

  23.         const res = await fetch("/register", {
  24.             method: "POST",
  25.             headers: {
  26.                 "Content-Type": "application/json"
  27.             }, body: JSON.stringify({
  28.                 fname, lname, email, subject, msg
  29.             })
  30.         });

  31.         console.log(res);


  32.     }


  33.     return (
  34.         <>
  35.             <div className="contact-form">
  36.                 <div className="contact-form-info">
  37.                     <div className="contact-title">
  38.                         <h3>TELL US YOUR PROJECT</h3>
  39.                     </div>
  40.                     <form id="contact-form">
  41.                         <div className="contact-page-form">
  42.                             <div className="contact-input">
  43.                                 <div className="contact-inner">
  44.                                     <input type="text" placeholder="First Name *" id="first-name" value={fname} onChange={(e) => setFname(e.target.value)} />
  45.                                 </div>
  46.                                 <div className="contact-inner">
  47.                                     <input type="text" placeholder="Last Name *" id="last-name" value={lname} onChange={(e) => setLname(e.target.value)} />
  48.                                 </div>
  49.                                 <div className="contact-inner">
  50.                                     <input type="text" placeholder="Email *" id="email" value={email} onChange={(e) => setEmail(e.target.value)} />
  51.                                 </div>
  52.                                 <div className="contact-inner">
  53.                                     <input type="text" placeholder="Subject *" id="subject" value={subject} onChange={(e) => setSubject(e.target.value)} />
  54.                                 </div>
  55.                                 <div className="contact-inner contact-message">
  56.                                     <textarea placeholder="Message *" value={msg} onChange={(e) => setMsg(e.target.value)}></textarea>
  57.                                 </div>
  58.                             </div>
  59.                             <div className="contact-submit-btn">
  60.                                 <button className="submit-btn" type="submit" onClick={sendEmail} >Send Email</button>
  61.                                 <p className="form-messege pt-3">{message}</p>
  62.                             </div>
  63.                         </div>
  64.                     </form>
  65.                 </div>
  66.             </div>
  67.         </>
  68.     )
  69. }

  70. export default ContactForm;
app.js

  1. const express = require("express");
  2. const app = express();
  3. const router = require("./routes/router");
  4. const cors = require("cors");

  5. const port = 8000
  6. app.use(express.json());
  7. app.use(cors());
  8. app.use(router);

  9. app.listen(port,()=>{
  10.     console.log(`Server start on port no : ${port}`)
  11. })
router.js existing quillreading.com
  1. const express = require("express");
  2. const router = new express.Router();
  3. const nodemailer = require("nodemailer");

  4. router.post("/register", (req, res) => {

  5.     const { fname, lname, email, subject, msg } = req.body;


  6.     try {
  7.         let transporter = nodemailer.createTransport({
  8.             host: "smtppro.zoho.in",
  9.             port: 465,
  10.             secure: true,   // true for 465, false for other ports
  11.             auth: {
  12.                 user: "info@mydomain.com",
  13.                 pass: "myAppPassword",
  14.             },
  15.         });

  16.         const mailOptions = {
  17.             from: "info@mydomain.com",
  18.             cc: "info@mydomain.com",
  19.             to: email,
  20.             subject: "Website Form",
  21.             html: 'First Name : ' + fname + '<br>' +
  22.                 'Last Name : ' + lname + '<br>' +
  23.                 'Email : ' + email + '<br>' +
  24.                 'Subject : ' + subject + '<br>' +
  25.                 'Message : ' + msg
  26.         }

  27.         transporter.sendMail(mailOptions, (error, info) => {
  28.             if (error) {
  29.                 console.log("Error", error)
  30.             } else {
  31.                 console.log("Email sent" + info.response);
  32.                 res.status(201).json({ status: 201, info })
  33.             }
  34.         })
  35.     } catch (error) {
  36.         res.status(401).json({ status: 401, error })
  37.     }
  38. });

module.exports = router;T
The Zoha emailer used to work properly on localhost when sending emails from my react and node js apps. The deployment did not work on my hosting. Giving this.


Response {type: 'basic', url: 'https://example.com/register', redirected: false, status: 200, ok: true, …}
    • Sticky Posts

    • Pocket from Mozilla is closing shop. Don’t lose your favorites . Move them to Zoho Mail Bookmarks now! 📥🔖

      The end of Pocket shouldn't mean the end of your important links and content. Easily import them into Zoho Mail's Bookmarks and continue right where you left off. You can bring over your entire Saves, Collections, and tags just the way they are. Bookmarks
    • Zoho Mail POP & IMAP Server Details

      Hello all! We have been receiving a number of requests regarding the errors while configuring or using Zoho Mail account in POP/ IMAP clients. The server details vary based on your account type and the Datacenter in which your account is setup. Ensure
    • Workplace - Zoholics Europe Customer Awards

      Dear Zoho Mail Community! 📣 We're excited to announce that at this year's Zoholics events across Europe, we're holding customer awards for the first time ever! Workplace - Zoholics Europe Customer Awards This is your chance to shout about the amazing
    • Important update on Group Management | Zoho Mail

      Dear Zoho Mail Community, This post is to inform you all of the following updates on the Group Management in Zoho Mail. Group Member Addition: If a group member is added to an organization group in a Zoho Application, the member will be automatically
    • Mastering email etiquette and best practices to follow in Zoho Mail

      Hello Zoho Mail Community, We’re thrilled to invite you all to our upcoming webinar: Mastering email etiquette and best practices to follow in Zoho Mail. Join our live webinar for expert etiquette tips to enhance your professionalism and elevate your