0

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 ?

Deepankar Bajpeyi
  • 5,661
  • 11
  • 44
  • 64

2 Answers2

4

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.

knitti
  • 6,817
  • 31
  • 42
  • great. Any workaround for this ? Do you suggest any other library for python ? :) – Deepankar Bajpeyi Feb 26 '14 at 09:15
  • 2
    you want to immediately (more or less) check whether an email address exists? That would be a spammers wet dream... you can check whether a domain exists by `dig` or `nslookup` (shell) or in python `socket.gethostbyname()` – knitti Feb 26 '14 at 09:18
  • haha. Great. I think I am gonna try postmark. Lets see if that helps. Thank you – Deepankar Bajpeyi Feb 26 '14 at 09:56
0

Smtplib only check email address format and smtp server (gmail in your case) queue the messages and return ok

pbacterio
  • 1,094
  • 6
  • 12