简体   繁体   English

Nodemailer 在我的本地主机上工作,但在我的远程服务器上不工作

[英]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.我的 nodemailer 有这个问题,它在我的本地主机上工作正常,但是当我将它拉到我的远程服务器上时它不起作用,给我 CONNTIMEOUT 错误。 Why does this happens?为什么会这样? Pratically, nodemailer doesn't create the transporter for my message which I define in successive part of my code实际上,nodemailer 不会为我在代码的连续部分中定义的消息创建传输器

   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.更改端口到端口:465。

Check for all this and it should work.检查所有这些,它应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 电子邮件验证 nodemailer 适用于本地主机,但不适用于服务器 - email verification nodemailer works on localhost but not on server Nodemailer,在本地工作正常,但在我的服务器上不起作用 - Nodemailer, works fine locally but doesn't work on my server 从远程服务器下载文件到我的本地主机 - download a file from a Remote Server to my Localhost GET请求Nodejs在本地主机上工作,但不在我的服务器上 - GET Request Nodejs works on localhost but not on my server NodeMailer 不适用于 Heroku 但它适用于 LocalHost,这是我的 index.js 请帮助 TT - NodeMailer does not work on Heroku but it works on LocalHost, this is my index.js please help T.T Stripe Payment 仅适用于我的 LocalHost,但不适用于 Heroku 服务器 - Stripe Payment Works only in my LocalHost but Does not work on Heroku server Nodemailer 适用于本地 PC,但不适用于服务器 - Nodemailer works on local PC, but not on server 为什么 Nodemailer 不能安全地连接到我在共享主机上运行的服务器 - Why Nodemailer does not securely connect to my server running on a shared host Node.js Express API “无法获取”所有路线。 适用于本地主机但不适用于我的服务器 - Node.js Express API “Cannot GET” with all routes. Works on localhost but not my server Nodemailer与我公司的电子邮件 - Nodemailer with my company's email
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM