Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream.on("end") is not called #171

Open
TheArKaID opened this issue Nov 29, 2021 · 1 comment
Open

Stream.on("end") is not called #171

TheArKaID opened this issue Nov 29, 2021 · 1 comment

Comments

@TheArKaID
Copy link

TheArKaID commented Nov 29, 2021

First, stream.on("end") will called after Data Ended. But how to get into this event ? I mean, I could end it if I use Telnet, just type "." (dot) and stream.on("end") will fired. But I tried with SMTP (nodemailer.createTransport), the "end" event is not called, I could even console.log(parsed) mail with MailParser, and it's stuck until Timed Out, which will give the Transport Timeout Response.

This is my onData callback,

        async onData(stream, session, callback) {
            stream.pipe(process.stdout);
            console.log('test123')
            let data = await mailparser(stream);
            // console.log(data)
            console.log('end123')
            stream.on('end', async () => {
                console.log('end')
                let err;
                if (stream.sizeExceeded) {
                    err = new Error('Error: message exceeds fixed maximum message size 10 MB');
                    err.responseCode = 552;
                    return callback(err);
                }

                callback(null, 'Message queued as abcdef'); // accept the message once the stream is ended
            });
        }

And the log looks like this,

[2021-11-29 06:49:25] DEBUG [#2olhr63d4yyjaq4o] C: DATA
test123
[2021-11-29 06:49:25] DEBUG [#2olhr63d4yyjaq4o] S: 354 End data with <CR><LF>.<CR><LF>
Message-ID: <[email protected]>
Date: Mon, 29 Nov 2021 13:49:24 +0700
Subject: Test Email . \n\n .
From: MyHealthcare <[email protected]>
To: [email protected]
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hello World!
end123
[2021-11-29 06:50:25] INFO  [#2olhr63d4yyjaq4o] Connection closed to [192.168.10.10]

Another information,

        logger: true
        secure: false,
        banner: 'Welcome to My Mail Service - SMTP Server'
        disabledCommands: ['STARTTLS']
        authMethods: ['PLAIN', 'LOGIN']
        size: 10 * 1024 * 1024
        useXClient: true
        hidePIPELINING: true
        useXForward: true
        SMTPServer.listen(587, 192.168.10.1)

Calling "stream.end()" doesn't call event "end" either. Or, should I just call callback(null, 'success')?

@krm35
Copy link

krm35 commented Jan 3, 2023

The stream end event is triggerred in the mailparser method.

#187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants