Check if Email Address Valid or Not in Python (original) (raw)

Last Updated : 8 Apr, 2026

Given a string that represents an email address, our task is to determine whether it follows the correct format. A valid email generally contains a username, @ symbol and a domain name. **For example:

**Valid: my.ownsite@our-earth.org, user123@gmail.com
**Invalid: myownsite.com, user@@gmail.com

Below are different methods to check if email address is valid or not in Python.

Using email_validator

This method uses email_validator package (not part of Python’s standard library) to validate emails by applying strict rules defined in email standards. It checks the username, domain format and whether the domain part is valid.

**Note: Before using methods, install the required third-party libraries using pip:
pip install email-validator validators

Python `

from email_validator import validate_email email = "abcd8@gmail.com" res = validate_email(email) print("Valid Email")

`

**Output

Valid Email

**Explanation:

Using validators Package

This method uses the validators package (not part of Python’s standard library) to check whether the email fits a valid pattern. It automatically examines the username, @ symbol and domain format together and returns True/False accordingly.

Python `

import validators

email = "my.ownsite@our-earth.org" if validators.email(email): print("Valid Email") else: print("Invalid Email")

`

**Output

Valid Email

**Explanation:

Using RegEx (re.fullmatch)

This method uses a regex pattern to match the entire email string. It validates each part ensuring the full email follows allowed character rules.

Python `

import re regex = r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,7}"

email = "my.ownsite@our-earth.org" print("Valid Email" if re.fullmatch(regex, email) else "Invalid Email")

email = "abc36.com" print("Valid Email" if re.fullmatch(regex, email) else "Invalid Email")

`

Output

Valid Email Invalid Email

**Explanation:

Using re.match

This method checks whether the email starts with a valid email pattern. It does not force the entire string to match, but still validates the username, @ and domain portion from the beginning.

Python `

import re

email = "my.ownsite@our-earth.org" pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$' valid = re.match(pattern, email)

print("Valid email." if valid else "Invalid email.")

`

**Explanation: