gpt4 book ai didi

node.js - Nodemailer,连接超时

转载 作者:太空宇宙 更新时间:2023-11-04 02:32:39 25 4
gpt4 key购买 nike

我正在使用nodemailer,https://github.com/andris9/Nodemailer .

我尝试了这个例子(当然更改了电子邮件)。它不起作用。什么也得不到安慰。 30-40 秒后我得到:

{ [Error: Connection timeout] code: 'ETIMEDOUT' }
Error: connect ETIMEDOUT
at errnoException (net.js:904:11)
at Object.afterConnect [as oncomplete] (net.js:895:19)

有什么可能出错的提示吗?如何调试?

这是示例中的代码。我将其粘贴到 server.js 中,因此它会在应用程序启动时触发。

var nodemailer = require('nodemailer');

// create reusable transporter object using SMTP transport
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'gmail.user@gmail.com',
pass: 'userpass'
}
});

// NB! No need to recreate the transporter object. You can use
// the same transporter object for all e-mails

// setup e-mail data with unicode symbols
var mailOptions = {
from: 'Fred Foo ✔ <foo@blurdybloop.com>', // sender address
to: 'bar@blurdybloop.com, baz@blurdybloop.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world ✔', // plaintext body
html: '<b>Hello world ✔</b>' // html body
};

// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
console.log(error);
}else{
console.log('Message sent: ' + info.response);
}
});

更新原来我的公司屏蔽了googlesmtp。所以代码没有任何问题。

最佳答案

Gmail 的问题已修复。如果您更改为其他电子邮件,它将起作用:)

关于node.js - Nodemailer,连接超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25198731/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com