Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 137755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:09:23+00:00 2026-05-11T07:09:23+00:00

I have a large number of email addresses to validate. Initially I parse them

  • 0

I have a large number of email addresses to validate. Initially I parse them with a regexp to throw out the completely crazy ones. I’m left with the ones that look sensible but still might contain errors.

I want to find which addresses have valid domains, so given me@abcxyz.com I want to know if it’s even possible to send emails to abcxyz.com .

I want to test that to see if it corresponds to a valid A or MX record – is there an easy way to do it using only Python standard library? I’d rather not add an additional dependency to my project just to support this feature.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:09:23+00:00Added an answer on May 11, 2026 at 7:09 am

    There is no DNS interface in the standard library so you will either have to roll your own or use a third party library.

    This is not a fast-changing concept though, so the external libraries are stable and well tested.

    The one I’ve used successful for the same task as your question is PyDNS.

    A very rough sketch of my code is something like this:

    import DNS, smtplib  DNS.DiscoverNameServers() mx_hosts = DNS.mxlookup(hostname)  # Just doing the mxlookup might be enough for you, # but do something like this to test for SMTP server for mx in mx_hosts:     smtp = smtplib.SMTP()     #.. if this doesn't raise an exception it is a valid MX host...     try:         smtp.connect(mx[1])     except smtplib.SMTPConnectError:         continue # try the next MX server in list 

    Another library that might be better/faster than PyDNS is dnsmodule although it looks like it hasn’t had any activity since 2002, compared to PyDNS last update in August 2008.

    Edit: I would also like to point out that email addresses can’t be easily parsed with a regexp. You are better off using the parseaddr() function in the standard library email.utils module (see my answer to this question for example).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large number of records (10,000, increasing every day) that essentially is
I have a large number of documents (mainly PDFs) that I want to index
I have a large number of csv files that look like this below: xxxxxxxx
I have a large number of instances of a C structure like this: struct
We have a large number of programmers on different platforms all using CVS. We
I have a large number of C# WCF services that are being called by
I have a large number of background reads and writes, and a much smaller
We have a large number of data in many categories with many properties, e.g.
I have a large number of objects which are identified by names (strings). So,
I have a large number of data points which are two dimensional coordinates with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.