简体   繁体   中英

Nodemailer works on my localhost but not on my remote server

I have this problem with nodemailer, which works fine on my localhost, but when I pull it on my remote server it doesn't works, giving me CONNTIMEOUT error. Why does this happens? Pratically, nodemailer doesn't create the transporter for my message which I define in successive part of my code

   const nodemailer = require('nodemailer');
    const smtpPool = require('nodemailer-smtp-pool')    

    let transporter = nodemailer.createTransport(smtpPool({
        service: "Gmail",
        port: 587,
        auth: {
            user: 'myuser@gmail.com',
            pass: 'mypass'
        },
        connectionTimeout: 10000,
        socketTimeout: 10000
    }));

    transporter.verify(function(error,success) {
        if(error) {
            res.send(error);
        } else {
            res.send("Server is ready to take our messages");
        }
    })

Try doing-

  1. Enable less secure apps
  2. Disabel captcha
  3. Changin port to port: 465.

Check for all this and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM