Closed krm35 closed 1 year ago
Hi there,
even without any parsing, the "end" event is not triggered. my code:
const SMTPServer = require("smtp-server").SMTPServer;
const server = new SMTPServer({
secure: false,
authMethods: [],
disabledCommands: [ "AUTH" ],
authOptional: true,
maxClients: 10,
hideSTARTTLS: true,
onData(stream, session, callback) {
stream.on('end', () => {
console.log(" --- ENDE --- ");
callback(null, 'OK')
});
},
});
server.listen(25);
an test Telnet Session:
220 ns03 ESMTP
ehlo blubb.at
250-ns03 Nice to meet you, xxxxxx
250-PIPELINING
250-8BITMIME
250 SMTPUTF8
MAIL FROM: <eee@blubb.at>
250 Accepted
RCPT TO: <data@blubb.at>
250 Accepted
DATA
354 End data with <CR><LF>.<CR><LF>
d
asd
as
das
d
.
-- hangs forever --
any hints?
thx, stefan
try this lib to send an email instead of telnet: https://github.com/guileen/node-sendmail
try this lib to send an email instead of telnet: https://github.com/guileen/node-sendmail
thats not the point - i even sent an E-Mail from Gmail to the script above, also raised a timeout, as the "end" event did not get triggered.
You need to pipe the stream and disable hideSTARTTLS
const {SMTPServer} = require("smtp-server");
const server = new SMTPServer({
secure: false,
authMethods: [],
disabledCommands: ["AUTH"],
authOptional: true,
maxClients: 10,
// hideSTARTTLS: true, // with this at true it wont work idk why
onData(stream, session, callback) {
stream.pipe(process.stdout);
stream.on('end', () => {
console.log(" --- ENDE --- ");
callback(null, 'OK')
});
},
});
server.listen(2525);
confirmed. that did the trick. thanks!
EDIT: the simpleParser triggers it that's why it's never triggered again.
Hello,
It seems that the stream doesn't trigger the end event , so the 250 OK isn't sent and services like protonmail try to resend the mail multiple times.
I call the callback after the parsing and it works but it shouldn't be done that way.