smtplib doesn't fail on invalid email addresses
-
21-12-2019 - |
Question
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.
OTHER TIPS
Smtplib only check email address format and smtp server (gmail in your case) queue the messages and return ok
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow