nodemailer / smtp-server

Create custom SMTP servers on the fly
Other
846 stars 145 forks source link

[NOT A BUG] Why does not a SMTP server work with secure option turned on? #151

Closed uWynell closed 4 years ago

uWynell commented 4 years ago
const fs = require('fs');
const {SMTPServer} = require('smtp-server');

const smtp = new SMTPServer({
    secure: true,
    key: fs.readFileSync('certs/privkey.pem'),
    cert: fs.readFileSync('certs/cert.pem'),
    onData,
    onRcptTo,
    authOptional: true,
});

function onRcptTo(address, session, callback) {
    console.log("IS HERE!!!");
    callback();
}

function onData(stream, session, callback) {
    stream.pipe(process.stdout);
}

smtp.listen(465);

Without secure option and post 25 accordingly all works, but not with it.

The certificate I got using Let's Encrypt through the Certbot. And also I tried to remain default certificate, but it doesn't work that way either.

So, why can this happen? Any ideas to fix this?

andris9 commented 4 years ago

"Does not work" is not a sufficient description. Figure out first what do you expect to happen and what actually happens. From that code I don't notice anything clearly wrong so probably the issue is somewhere in your system

almostkareem commented 2 years ago

Hello @uWynell did you manage to fix this, i get SSL WRONG VERSION everytime i set secure to true.

uWynell commented 2 years ago

Hello @uWynell did you manage to fix this, i get SSL WRONG VERSION everytime i set secure to true.

No I didnt; I just continued without the secure options turned on. And as for your problem, I got the same error when tried connect to a local proxy via https. When exactly do you get this error? (e.g. when the server starts up or when you are trying to send a letter to it) Are you trying to send a letter from localhost to localhost, maybe?

almostkareem commented 2 years ago

I can't even get past EHLO Command. when I put secure to true

uWynell commented 2 years ago

I can't even get past EHLO Command. when I put secure to true

Oh.. Then I don't think I can help you