I’m trying to understand how this works.
When I normally send and email and the recipient doesn’t exist, or some other error occurs, an email is send back containing the info about the error and the status. This can take some time.
My question here is how can smtplib catch this error if this response take time?
When I send an email using smtplib it never raises the SMTPRecipientsRefused exception. It just sends the email and later, when purposely using an invalid email address, I get the “Delivery to the following recipient failed permanently:” error in my reply-to email box. This doesn’t help me as I am trying to clean my email address database from invalid email addresses.
There is the verify function:
SMTP.verify(address)
But I don’t believe this is a real option. Note from python docs on VRFY:
“Many sites disable SMTP VRFY in order to foil spammers.”
A note on my testing environment: I’m using django and a remote SMTP server (gmail/apps).
Q1: Is this the reason for not being able to catch the error? Should I be using a local server?
Q2: Is there a way to do this except from parsing my actual error emails from the reply-to email box?
Thanks in advance for any thoughts on the matter!
No idea what your application is, but another option if you have an associated website is to periodically ask your users upon login to verify/update their email address.