format_align_left
code
Python
verified
Free Download
devices
Cross-platform
code Code Preview
Python#!/usr/bin/env python3
"""
Email Normalizer
Standardize email addresses across your lists
"""
import re
def normalize_email(email):
"""Normalize a single email address"""
email = email.strip().lower()
# Split local and domain parts
if '@' not in email:
return None
local, domain = email.rsplit('@', 1)
# Gmail-specific: remove dots and plus addressing
if domain in ['gmail.com', 'googlemail.com']:
local = local.replace('.', '')
if '+' in local:
local = local.split('+')[0]
domain = 'gmail.com' # Normalize googlemail
# Common domain fixes
domain_fixes = {
'gmial.com': 'gmail.com',
'gmai.com': 'gmail.com',
'hotmal.com': 'hotmail.com',
'yaho.com': 'yahoo.com',
}
domain = domain_fixes.get(domain, domain)
# Remove leading/trailing spaces and dots
local = local.strip('.')
domain = domain.strip('.')
return f"{local}@{domain}"
def normalize_list(emails):
"""Normalize a list of emails"""
normalized = []
for email in emails:
result = normalize_email(email)
if result:
normalized.append(result)
return list(set(normalized)) # Remove duplicates
if __name__ == '__main__':
import sys
emails = open(sys.argv[1]).read().splitlines()
normalized = normalize_list(emails)
print(f"Original: {len(emails)}, Normalized: {len(normalized)}")
info About This Tool
The Email Normalizer standardizes email addresses to canonical form. Handles Gmail dot tricks, plus addressing, common typos, and case normalization.
Key Features
- Gmail Normalization - Removes dots and plus tags from Gmail addresses
- Typo Correction - Fixes common domain typos (gmial, hotmal, etc.)
- Case Normalization - Converts all emails to lowercase
- Whitespace Cleanup - Trims spaces and invisible characters
- Deduplication - Identifies duplicates after normalization
Normalization Rules
- john.doe@gmail.com = johndoe@gmail.com
- john+promo@gmail.com = john@gmail.com
- User@DOMAIN.COM = user@domain.com
- user@gmial.com = user@gmail.com
Requirements
- Python 3.7+
- No external dependencies
download Download Script
Need Full Automation?
Try Postigo for automated email campaigns with AI personalization
rocket_launch Start Free Trial