Emails Not Sending from Production Server; Send Perfectly Fine from Development Server

Hello,

I have been trying to debug this issue for quite a while and no solutions online seem to fix it. I am using an open relay SMTP email server as my host and using port 25 in settings.py. These setting works fine when I am testing locally from my development server and send_email is successful. However, when I try to send an email from the production server, emails are not sent, and I do not receive any kind of error message.

I’ve found that the logs in the firewall on the SMTP server are never receiving the email from the django website. I’ve tried a few things for debugging as well:

  1. I tested to make sure emails are working using that SMTP server per this post
  2. I implemented the django email log. From this I found that the emails are getting logged but are failing to send.
    image

Does anyone have a potential solution I could try?

Are there any debugging tips I could apply?

Update: I was able to get an error message from the send_mail function. Here is the error I’m getting: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1000)

Thanks,
Ivan

SOLUTION FOUND:

Apparently, the problem arises from later Django versions and the solution to the issue is to create your own email backend. The video with the required code can be found on youtube here.

Avoid port 25 no matter what.
You can’t establish secure connections on that port as it’s uncryptable. use TLS on 465 or 587.
It works like a charm with sendmail in Django