nodemailer / smtp-server

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

SSL ERROR ERR_SSL_SSLV3_ALERT_BAD_CERTIFICATE #168

Closed almostkareem closed 2 years ago

almostkareem commented 2 years ago

Hello, I have been using this package to receive inbound emails, but some mail servers like gitlab or dribbble cannot send messages to my SMTP server, this the error I get :

Capture d’écran 2021-09-14 à 5 59 06 p m

Thanks, any help appreciated

andris9 commented 2 years ago

Most probably your TLS certificate is not valid (either expired or CA chain is missing) and these clients are validating the certificate.

almostkareem commented 2 years ago

I have not set up any TLS Certificate.

andris9 commented 2 years ago

In this case SMTP-server is using self generated certificates that are always invalid. You need to provide valid certificates in order to accept mail.

almostkareem commented 2 years ago

Please can you give me a doc or something something to achieve this?

andris9 commented 2 years ago

See the docs here https://nodemailer.com/extras/smtp-server/#tls-and-startls-notice

almostkareem commented 2 years ago

After setting up a certificate and a private key I now get : Error: Socket closed unexpectedly 20|mail-api | at TLSSocket.onError (/var/apps/mail-api/node_modules/smtp-server/lib/smtp-server.js:473:29)

Zonalds commented 2 years ago

@andris9 I do get the same exact error after setting up the certificate and key. The certificate was issued by Let's encrypt for the host

secure: true, key: fs.readFileSync("/etc/letsencrypt/live/mail-smtp.sendus.io/privkey.pem"), cert: fs.readFileSync("/etc/letsencrypt/live/mail-smtp.smtp.sendus.io/fullchain.pem"), //Also tried to use cert.pem with no sucess

 Error: Socket closed unexpectedly
20|mail-api | at TLSSocket.onError (/var/apps/mail-api/node_modules/smtp-server/lib/smtp-server.js:473:29)

Any chance you could help with this?