Nodemailer:ECONNREFUSED [英] Nodemailer: ECONNREFUSED

查看:236
本文介绍了Nodemailer:ECONNREFUSED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道自己缺少什么,我使用Nodemailer示例:

I don't know what I'm missing, I use the Nodemailer example:

var nodemailer = require("nodemailer");

// create reusable transport method (opens pool of SMTP connections)
var smtpTransport = nodemailer.createTransport("SMTP",{
    service: "Gmail",
    auth: {
        user: "gmail.user@gmail.com",
        pass: "userpass"
    }
});

// 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
smtpTransport.sendMail(mailOptions, function(error, response){
    if(error){
        console.log(error);
    }else{
        console.log("Message sent: " + response.message);
    }

    // if you don't want to use this transport object anymore, uncomment following line
    //smtpTransport.close(); // shut down the connection pool, no more messages
});

我刚刚更改了用户并将auth传递给我的gmail帐户信息(也尝试了其值),然后将至"电子邮件地址更改为我的电子邮件地址.我得到:

I just changed the user and pass in auth to my gmail account info (also tried with their values), and I changed the "to" email address to my email address. I get:

{ [Error: connect ECONNREFUSED]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect' }

我想念什么?我在文档中看不到任何说明我需要做的事情,为什么它不起作用?预先谢谢你.

What am I missing? I don't see anything in the documentation that says I need to do anything more than this, so why won't it work? Thank you in advance.

推荐答案

这是防火墙问题.原来代码没有错,我只是不明白错误消息的含义.

It was a firewall issue. Turns out there was nothing wrong with the code, I just didn't understand what the error message implied.

这篇关于Nodemailer:ECONNREFUSED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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