Skip to content

Instantly share code, notes, and snippets.

@arjunsinghy96
Last active September 17, 2018 12:22
Show Gist options
  • Save arjunsinghy96/dbce8193750adcaa50a09c0bbe239e13 to your computer and use it in GitHub Desktop.
Save arjunsinghy96/dbce8193750adcaa50a09c0bbe239e13 to your computer and use it in GitHub Desktop.
from smtplib import SMTP
address_to_test = "arjunsinghy96@gmail.com"
try:
with SMTP('gmail-smtp-in.l.google.com') as smtp:
host_exists = True
smtp.helo() # send the HELO command
smtp.mail('admin@emailgardener.com') # send the MAIL command
resp = smtp.rcpt(address_to_test)
if resp[0] == 250: # check the status code
deliverable = True
elif resp[0] == 550:
deliverable = False
else:
print(resp[0])
except smtplib.SMTPServerDisconnected as err:
print("SMTP connection error")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment