[英].href.replace giving me double domain (http://localhosthttp://mydomain.com)
[英]nodemailer smtp-server giving 421 mydomain.com You talk too soon error
我正在使用http://nodemailer.com/extras/smtp-server/運行 SMTP 服務器來接受所有郵件提交。
當郵件提交代理使用 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
但是,這種情況只發生在某些客戶端上,我嘗試過使用其他一些工具,它可以將連接升級到 TLS,沒有任何問題。
以下是我的服務器配置選項。
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);
能夠通過在 nodemailer smtp-server 模塊中注釋代碼的某些部分來解決這個問題。 只是在這里發布,以便它可以幫助其他正在尋求相同答案的人。
一些 SMTP 客戶端,比如我使用的那個,在連接后不等待服務器響應,而是向服務器發送 EHLO 或 HELO 命令。 從模塊的源代碼來看,這些客戶端被視為早期談話者,並且連接被阻止以避免垃圾郵件。
評論超時函數並發出 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();
});
}
如果需要時間,還要禁用反向查找。
// disabling the reverse lookup which will solve 'you talk so soon problem'
this.options.disableReverseLookup = true;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.