{[错误:连接到SMTP服务器时超时]代码:4,SMTP:未定义} [英] { [Error: timedout while connecting to smtp server] code: 4, smtp: undefined }

查看:44
本文介绍了{[错误:连接到SMTP服务器时超时]代码:4,SMTP:未定义}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在nodejs中发送邮件.所以我已经安装了emailjs.我已将脚本配置如下.

I am going to send mail in nodejs. So I have installed emailjs. I have configured the script as the followings.

emailjs = require('emailjs');

var server = emailjs.server.connect({
        user:"my gmail address",
        password:"gmail passs word",
        host:"smtp.gmail.com",
        ssl:true,
        port: 456
      });

 server.send({
          text: "message",
          from:"LLVC <my outlook mail>",
          to:"<my outlook mail>",
          subject:"Subject"
        },
        function (err, message) {
        console.log(err || message);
    });

但是我得到了错误

{ [Error: timedout while connecting to smtp server] code: 4, smtp: undefined }

我要修复它们.谢谢.

推荐答案

以防万一其他人正在寻找答案.对我有用的是将ssl设置为true,将tls设置为false.添加smtp端口无济于事.话虽如此,以下是有效的smtp端口:25、465、587和2525.我希望这对其他人有所帮助.

Just in case someone else is looking for an answer. What worked for me was setting ssl to true and tls to false. Adding smtp port didn't help. With that been said the following are valid smtp ports: 25, 465, 587, and 2525. I hope this helps somebody else.

这篇关于{[错误:连接到SMTP服务器时超时]代码:4,SMTP:未定义}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆