How to find if a given mail id exists

There are a few ways to check if a given email address exists:

Method 1: Using a simple email validation library

You can use a library like email-validator in Python or email-validator in JavaScript to validate the email address. These libraries can check if the email address is in a valid format, but they cannot confirm if the email address actually exists.

Here's an example in Python:

import email_validator

try:
    email_validator.validate_email('[email protected]')
    print("Email address is valid")
except email_validator.EmailNotValidError:
    print("Email address is not valid")

Method 2: Using a email verification API

There are several email verification APIs available that can check if an email address exists. These APIs typically work by sending a verification email to the email address and then checking if the email address is valid by looking for a response from the email server.

Here are a few examples of email verification APIs:

Here's an example of how to use the Mailgun API in Python:

import requests

api_key = "YOUR_MAILGUN_API_KEY"
domain = "YOUR_MAILGUN_DOMAIN"

url = f"https://api.mailgun.net/v3/{domain}/address/validate"
params = {"address": "[email protected]"}
headers = {"Authorization": f"Basic {api_key}"}

response = requests.get(url, params=params, headers=headers)

if response.status_code == 200:
    print("Email address exists")
else:
    print("Email address does not exist")

Method 3: Using a email lookup service

There are several email lookup services available that can provide information about an email address, including whether it exists or not. These services typically work by querying a database of known email addresses.

Here are a few examples of email lookup services:

Here's an example of how to use the Hunter API in Python:

import requests

api_key = "YOUR_HUNTER_API_KEY"

url = "https://api.hunter.io/v2/email-verifier"
params = {"email": "[email protected]"}
headers = {"Authorization": f"Bearer {api_key}"}

response = requests.get(url, params=params, headers=headers)

if response.status_code == 200:
    print("Email address exists")
else:
    print("Email address does not exist")

Note that these methods are not foolproof and may not always return accurate results. Email addresses can be invalid or non-existent, and some email verification APIs may not always be able to verify the existence of an email address.