Search code examples
pythondjangoemailsmtplibdjango-email

smtplib doesn't fail on invalid email addresses


In django, I tried sending a mail using send_mail like :

from django.core.mail import send_mail
send_mail("test", "test", settings.EMAIL_HOST_USER, ["sasdadome@asdijandasd.com"])

This surprisingly sends me a status of 1, which means it was delivered successfully .

If I try sending the same using my gmail account, I get a failure response immediately.

How do I catch such failures with smtplib ?


Solution

  • This email adress is very valid. It just doesn't exist. Neither django nor smtplib verify whether a domain exists. They just deliver the mail to an MTA which reacts appropiately.