VinnyVincent
VinnyVincent

Reputation: 1

Web form's will send to STMP email address on my shared hosting account, but not to gmail, yahoo, ect

I tried searching for this, but I might just not know how to word the search right...

I have tried setting up web forms using both Node.js(express) and php with the same issue: The email with the form data will send to my domain name email addresses no problem, even when I have the form page hosted on a different VPS provider than my shared hosting email address with my domain name. When I try to send the data to any other email address, like yahoo, gmail, ect, I get redirected to the "success" page, my console log on the server says success, but the email never actually goes through. I've tried various configurations and I keep getting the same result. I've even tried sending it from different email accounts and I am getting the same result. I can't even get a yahoo account to mail to the same yahoo account, but that same yahoo account will send mail to my shared hosting email no problem. Here is a sample of the Node.js version of the code I am trying to use:

    app.post('/send', (req, res) => {
    const output = `
    <p> you have a new contact request</p>
    <h3>Contact Details</h3>
    <ul>
    <li>Name: ${req.body.name}</li>
    <li>Email: ${req.body.email}</li>
    <li>Phone: ${req.body.phone}</li>
    </ul>
    `;


    // create reusable transporter object using the default SMTP transport
    let transporter = nodemailer.createTransport({
    host: 'mail.my-little-pwny.com',
    port: 465,
    secure: true, // true for 465, false for other ports
    auth: {
        user: '[email protected]', //  username
        pass: 'abc123' //  password
    },
    tls: {
        rejectUnauthorized:false
      }
   });

   // setup email data with unicode symbols
   let mailOptions = {
    from: '"Nodemailer" <[email protected]>', // sender address
    to: '[email protected]', // list of receivers
    subject: 'Client Contact Request', // Subject line
    text: 'Hello world?', // plain text body
    html: output // html body
   };

   // send mail with defined transport object
   transporter.sendMail(mailOptions, (error, info) => {
    if (error) {
        return console.log(error);
    }
    console.log('Message sent: %s', info.messageId);
    console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));

      res.render('index', {msg:'Success! We will contact you as soon as 
   possible!'});
   });
   });

Upvotes: 0

Views: 169

Answers (1)

Pavan Nagadiya
Pavan Nagadiya

Reputation: 682

it's possible,

first of all you have to forward your personaldomain.com to the g-mail from the C-panel by adding mx records in the domain too. And after set the SMTP of the g-mail in to the PHPMailer.

How to Use Your Domain with Gmail

Upvotes: 1

Related Questions