[英]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.