Skip to main content

Smart SMTP email verifier which can even bypass greylisting!

Project description

Grey verifier: Smart SMTP Email Verifier (python)

Grey Verifier makes correct SMTP conversation to verify email address or list of addresses and properly handles 4xx SMTP errors (such as greylisting).

This tool could be slow - it's not working parallel.

verifier prints successfully verified email addresses to stdout, and failed addresses (and reason) to stderr.

Why yet another mail list verifier?

Because many other verifiers are working incorrectly, e.g. They use incorrect HELO host, do not issue MAIL FROM command before RCPT TO and on some mailserver this makes incorrect result (e.g. RCPT TO fails because of missed MAIL FROM, but not because something wrong with recipient).

SMTP Email verifier:

  1. Connects to main MX for domain (with lowest MX priority)
  2. Makes correct (configurable) SMTP conversation with HELO / MAIL FROM / RCPT TO
  3. For each failed email prints (easy to parse with cut -f 1 -d: )
  4. Supports Greylisting! If verification returns a temporary error, it will retry every --retry seconds for up to --max-retry seconds.

Install

pipx install grey-verifier

Usage

Verify one email address

$ grey_verifier yaroslaff@gmail.com
yaroslaff@gmail.com

$ grey_verifier yaroslaff-NoSuchEmail@gmail.com
yaroslaff-NoSuchEmail@gmail.com: RCPT TO error: 550 b"5.1.1 The email account that you tried to reach does not exist. Please try\n5.1.1 double-checking the recipient's email address for typos or\n5.1.1 unnecessary spaces. For more information, go to\n5.1.1  https://support.google.com/mail/?p=NoSuchUser 38308e7fff4ca-2ef05d163c2si289891fa.270 - gsmtp"

Optionally provide options --helo HOSTNAME and --from ADDRESS. Some mail servers will give false negative results if will not like HELO or FROM address.

Verify list

# See verification status for each email address
$ grey_verifier -f /tmp/test.txt 
aaa@example.com: DNS error for example.com
bbb@example.com: DNS error for example.com
yaroslaff@gmail.com

# Get only verified emails
$ grey_verifier -f /tmp/test.txt 2> /dev/null 
yaroslaff@gmail.com

# Or with redirections and custom HELO and MAIL FROM address
$ grey_verifier -f /tmp/test.txt --helo localhost --from noreply@example.com > /tmp/test-ok.txt 2> /tmp/test-fail.txt
# now get all failed addresses:
$cut -f 1 -d: < /tmp/test-fail.txt

Greylisting

To pass greylisting protection, use --max-retry N option to set retry limit (in seconds). If --max-retry is set, verifier will retry every --retry N seconds (default: 60), for up to --max-retry limit.

Note: Default value for --max-retry is 0 (retries disabled). Set it to something like --max-retry 600 (or even more) to properly handle greylisting.

Verbose

If you want to see how exactly verification happens for email address, use -v / --verbose to see internal debug messages and -s / --smtp-verbose to see SMTP conversation. Example:

$ email_verifier -sv yaroslaff@gmail.com
# Verifying yaroslaff@gmail.com
connect: to ('gmail-smtp-in.l.google.com.', 25) None
reply: b'220 mx.google.com ESMTP 2adb3069b0e04-52ed252cfc0si2901698e87.159 - gsmtp\r\n'
reply: retcode (220); Msg: b'mx.google.com ESMTP 2adb3069b0e04-52ed252cfc0si2901698e87.159 - gsmtp'
connect: b'mx.google.com ESMTP 2adb3069b0e04-52ed252cfc0si2901698e87.159 - gsmtp'
send: 'helo mir.localdomain\r\n'
reply: b'250 mx.google.com at your service\r\n'
reply: retcode (250); Msg: b'mx.google.com at your service'
send: 'mail FROM:<noreply@example.com>\r\n'
reply: b'250 2.1.0 OK 2adb3069b0e04-52ed252cfc0si2901698e87.159 - gsmtp\r\n'
reply: retcode (250); Msg: b'2.1.0 OK 2adb3069b0e04-52ed252cfc0si2901698e87.159 - gsmtp'
send: 'rcpt TO:<yaroslaff@gmail.com>\r\n'
reply: b'250 2.1.5 OK 2adb3069b0e04-52ed252cfc0si2901698e87.159 - gsmtp\r\n'
reply: retcode (250); Msg: b'2.1.5 OK 2adb3069b0e04-52ed252cfc0si2901698e87.159 - gsmtp'
send: 'quit\r\n'
reply: b'221 2.0.0 closing connection 2adb3069b0e04-52ed252cfc0si2901698e87.159 - gsmtp\r\n'
reply: retcode (221); Msg: b'2.0.0 closing connection 2adb3069b0e04-52ed252cfc0si2901698e87.159 - gsmtp'

yaroslaff@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grey_verifier-0.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

grey_verifier-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file grey_verifier-0.1.1.tar.gz.

File metadata

  • Download URL: grey_verifier-0.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for grey_verifier-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a6fb754a1064ae96ffb7c040ade70ebe3985b3ade024b2d18c40d43de46ea6c8
MD5 20c202307fda4d6d358d756405aee37d
BLAKE2b-256 4a28161cc58fb9dc4cd1b4867568fa0bb3f04141c6147ccffe448d2a87f7228a

See more details on using hashes here.

File details

Details for the file grey_verifier-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for grey_verifier-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d9d575784283b57c01fded1a690c9a4eea8457a5d9cc7c4381c06484933bd101
MD5 fc3da05eb7115481a10bc75db8bf4a50
BLAKE2b-256 af0bfb75027dd290d72f68ae07b805d1d36b6de1f6ec9fbb6452a0697902f672

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page