简体   繁体   English

nodemailer smtp-server 给出 421 mydomain.com 你说得太早了错误

[英]nodemailer smtp-server giving 421 mydomain.com You talk too soon error

I am running an SMTP Server using http://nodemailer.com/extras/smtp-server/ to accept all the mail submissions.我正在使用http://nodemailer.com/extras/smtp-server/运行 SMTP 服务器来接受所有邮件提交。
When the mail submission agent uses STARTTLS I get the following error.当邮件提交代理使用 STARTTLS 时,我收到以下错误。

5|producer  | [2020-10-09 07:28:52] DEBUG [#ff7cqlwi7rat6z2k] C: EHLO qa.mydomain.com
5|producer  | [2020-10-09 07:28:52] DEBUG [#ff7cqlwi7rat6z2k] S: 421 mydomain.com You talk too soon
5|producer  | [2020-10-09 07:28:52] INFO  [#ff7cqlwi7rat6z2k] Connection closed to 91.198.201.301

However, this happens only with some clients and I have tried with few other tools and it upgrades the connection to TLS without any issue.但是,这种情况只发生在某些客户端上,我尝试过使用其他一些工具,它可以将连接升级到 TLS,没有任何问题。

Below are my server configuration options.以下是我的服务器配置选项。

SMTPServerOptions = { 
  secure: false,
  hideSTARTTLS:true,
  authOptional: true,
  debug: true,
  logger: true,
  onAuth,
  onData
}

if(conf.tls) {
  SMTPServerOptions.ca = fs.readFileSync('./certificates/chain.pem', 'ascii')
  SMTPServerOptions.key = fs.readFileSync('./certificates/privkey.pem','ascii')
  SMTPServerOptions.cert = fs.readFileSync('./certificates/cert.pem','ascii')
}
//creating new SMTP object
const server = new SMTPServer(SMTPServerOptions);

server.on('error', err => {
  error(err)
  throw err 
});

server.listen(conf.server_port);


Was able to solve this by commenting some parts of the code in the nodemailer smtp-server module.能够通过在 nodemailer smtp-server 模块中注释代码的某些部分来解决这个问题。 Just posting here so that it would help others who are seeking the answer for the same.只是在这里发布,以便它可以帮助其他正在寻求相同答案的人。

Some SMTP clients like the one which I used do not wait for the server response after the connection and sends the EHLO or HELO command to the server.一些 SMTP 客户端,比如我使用的那个,在连接后不等待服务器响应,而是向服务器发送 EHLO 或 HELO 命令。 From the source code of the module, these clients are treated as early talkers and the connection is blocked to avoid spamming.从模块的源代码来看,这些客户端被视为早期谈话者,并且连接被阻止以避免垃圾邮件。
Commenting the timeout function and emitting connectionReady() event immediately solved the problem.评论超时函数并发出 connectionReady() 事件立即解决了问题。

     /**
     * Initiates the connection. Checks connection limits and reverse resolves client hostname. The client
     * is not allowed to send anything before init has finished otherwise 'You talk too soon' error is returned
     */
    init() {
        // Setup event handlers for the socket
        this._setListeners(() => {
            // Check that connection limit is not exceeded
            if (this._server.options.maxClients && this._server.connections.size > this._server.options.maxClients) {
                return this.send(421, this.name + ' Too many connected clients, try again in a moment');
            }
            // Keep a small delay for detecting early talkers
            //setTimeout(() => this.connectionReady(), 100);

            // no need to detect the early talkers
            this.connectionReady();
        });
    }

Also disable the reverse lookup if it is taking time.如果需要时间,还要禁用反向查找。

 // disabling the reverse lookup which will solve 'you talk so soon problem'
 this.options.disableReverseLookup = true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .href.replace给我双重域名(http:// localhosthttp://mydomain.com) - .href.replace giving me double domain (http://localhosthttp://mydomain.com) SMTP-server npm 收不到邮件数据 - SMTP-server npm does not receive the mail data 在 aws 上使用 Godaddy SMTP 服务器的 Nodemailer 连接超时错误 - Nodemailer connection timeout error using Godaddy SMTP server on aws 如何在新标签页中打开 document.location.replace('//mydomain.com/sdfs?id='+myvar) URL? - How to Open document.location.replace('//mydomain.com/sdfs?id='+myvar) URL in new tab? htacess将主页重定向到mydomain.com时,使用ajax内部链接到主页(/ index) - internaly linking to home page (/index) using ajax when htacess redirects home page to mydomain.com Nodemailer提供了错误 - Nodemailer is giving error 如何制作 mydomain.com/someID 类型的 URL ,其中 someID 来自 firestore 中的字段(doc)? - How to make a URL of type mydomain.com/someID where someID comes from a field (doc) in the firestore? 提交表单后,将数据插入Mysql并将用户重定向到URL mydomain.com/entries/last_inserted_id - After form submit, insert data into Mysql and redirect user to an url mydomain.com/entries/last_inserted_id 如果未发送电子邮件,Nodemailer 不会出错 - Nodemailer not giving error if email not sent SMTP服务器出现错误。 邮件未在Meteor App中发送 - SMTP server giving error. Mails not being sent in Meteor App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM