{代码:4,smtp:undefined}

我将在nodejs中发送邮件。 所以我已经安装了emailjs。 我已经configuration了以下脚本。

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 } 

我想解决它们。 谢谢。

这是端口465,而不是456。

If you tried configuring your SMTP server on port 465 (with SSL) and port 587 (with TLS), but are still having trouble sending mail, try configuring your SMTP to use port 25 (with SSL).

https://support.google.com/mail/answer/78775?hl=en

以防万一别人在寻找答案。 我的工作是将ssl设置为true,并将其设置为false。 添加smtp端口没有帮助。 有人说,以下是有效的smtp端口:25,465,587和2525.我希望这可以帮助别人。