为什么会收到NodeMailer HELO 501主机名错误?

时间:2018-10-11 23:28:39

标签: node.js smtp lets-encrypt nodemailer starttls

当我尝试连接到NodeMailer SMTP服务器(恰好在同一台计算机上)时,出现NodeMailer错误:

error:  { Error: Invalid HELO. response=501 Error: Syntax: HELO hostname: 501 Error: Syntax: HELO hostname
    at SMTPConnection._actionHELO (/home/hunter/projects/proxy-e/node_modules/nodemailer/lib/smtp-connection/index.js:1139:27)
    at SMTPConnection._processResponse (/home/hunter/projects/proxy-e/node_modules/nodemailer/lib/smtp-connection/index.js:762:20)
    at SMTPConnection._onData (/home/hunter/projects/proxy-e/node_modules/nodemailer/lib/smtp-connection/index.js:558:14)
    at TLSSocket._socket.on.chunk (/home/hunter/projects/proxy-e/node_modules/nodemailer/lib/smtp-connection/index.js:510:47)
    at TLSSocket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at TLSSocket.Readable.push (_stream_readable.js:219:10)
    at TLSWrap.onread (net.js:639:20)
  code: 'EPROTOCOL',
  response: '501 Error: Syntax: HELO hostname',
  responseCode: 501,
  command: 'HELO' }

我正在尝试通过以下方式进行连接:

let optionsTwo = {
    port: 465,
    host: 'mydomain.com',
    secure: true,
    name: 'mydomain.com',
    transactionLog: true,
    debug: true,
};

const connection = new SMTPConnection(optionsTwo);

connection.connect(function() {
    console.log("connected?");

    let authTwo = {
        user: 'foo',
        pass: 'bar'
    };

    connection.login(authTwo, function(err) {
        if (err) {
            console.log("err::", err);
        }
        console.log("logged in?");
    });

});

connection.on("error", function(err) {
    console.log("error: ", err);
});

我的NodeMailer服务器:

let options = {
    secure: false,
    authOptional: false,
    secure: true,
    key: hskey,
    cert: hscert,
    ca: [hschain],
    onAuth(auth, session, callback) {
    ...
    },
}

const emailServer = new SMTPServer(options);

emailServer.listen(465);

我的服务器具有注册的域名和来自LetsEncrypt的证书。我无法弄清楚为什么我继续得到这个HELO hostname 501 error。通过深入研究NodeMailer JS文件,我发现了这一点:

  

处理服务器对STARTTLS命令的响应。如果有错误        *尝试HELO,否则启动TLS升级。如果升级        *成功重启EHLO

这让我假设STARTTLS出现某种错误,因此它尝试使用HELO并失败了,但是为什么?

1 个答案:

答案 0 :(得分:0)

由于某种原因{{1}}不正确,并且在删除它时,我不再遇到错误。