namshi / docker-smtp

SMTP docker container
MIT License
548 stars 198 forks source link

After setting values for CERTIFICATE_PATH and KEY_PATH, still can send emails without certs #68

Open ericqqqqq opened 4 years ago

ericqqqqq commented 4 years ago

Problem Hi, I am using namshi/smtp to be my smarthost SMTP relay for SendGrid. I need to enable TLS so that the SMTP replay only handles requests with certs. Therefore, I set the values for CERTIFICATE_PATH and KEY_PATH to enable TLS.

Performed I ran the following command to initialize the container:

docker run -p 25:25 -v $(pwd)/:/etc/ssl/certs \
    -e "KEY_PATH=/etc/ssl/certs/MyKey.key" \
    -e "CERTIFICATE_PATH=/etc/ssl/certs/MyCertificate.crt" \
    -e "SMARTHOST_ADDRESS=smtp.sendgrid.net" \
    -e "SMARTHOST_USER=apikey" \
    -e "SMARTHOST_ALIASES=*" \
    -e "SMARTHOST_PORT=587" \
    -e "SMARTHOST_PASSWORD=MY_API_KEY" \
    namshi/smtp

Then I sent a testing email with this code

Expected Result The email is supposed to be blocked because no cert is provided.

Actual Result The email is sent.

Any suggestions?

ericqqqqq commented 4 years ago

Hey, @oba11

I added a feature to allow TLS for a smart host, SendGrid in my case. Check here for my implementation.

My implementation works perfectly for my needs. It would be cool if we try to merge it to your master. I am here for your feedbacks.

Here are some example codes to test the feature I added.