What is Email Provider Links?
Email Provider Links is a completely free and open source JavaScript/TypeScript library that automatically detects email providers and retrieves their login URLs. It helps create seamless user experiences by guiding users directly to their email inbox after registration or email verification. 100% Free Forever:
How does it work?
The library uses a multi-step detection process that combines fast database lookups with intelligent DNS analysis. Here's exactly what happens when you call getEmailProvider(email):
Step 1: Email Parsing & Normalization
First, the email address is parsed and normalized:
- Extracts the domain from the email (e.g.,
example.comfromuser@example.com) - Normalizes Gmail addresses by removing dots and plus aliases (e.g.,
john.doe+tag@gmail.com→johndoe@gmail.com) - Handles common email alias patterns for other providers
Step 2: Domain Database Lookup
The library maintains a comprehensive database of 218+ email domains mapped to their providers. This includes:
- Consumer providers: gmail.com → Gmail, outlook.com → Microsoft Outlook, yahoo.com → Yahoo Mail, etc.
- International variants: gmail.co.uk, outlook.fr, yahoo.co.jp, and many more
- Provider aliases: Multiple domains pointing to the same provider (e.g., hotmail.com, live.com → Outlook)
Result: If found, returns instantly with detectionMethod: 'domain_match' (typically <1ms).
Step 3: DNS MX Record Analysis
If the domain isn't in the database (common for business/custom domains), the library performs DNS lookups:
- MX Record Query: Queries DNS for Mail Exchange (MX) records to find the mail server
- Pattern Matching: Analyzes MX record hostnames for known patterns:
*.google.comor*.googlemail.com→ Google Workspace*.outlook.com,*.office365.com,*.mail.protection.outlook.com→ Microsoft 365*.yahoo.com,*.yahoodns.net→ Yahoo Mail- And many more patterns for other providers
- Timeout Protection: DNS queries are limited by a configurable timeout (default 5 seconds) to prevent hanging
Result: If a pattern matches, returns with detectionMethod: 'mx_record' or detectionMethod: 'mx_pattern' (typically 50-500ms depending on DNS response time).
Step 4: Heuristic Detection
For domains that don't match known patterns, the library uses heuristics to detect:
- Email Alias Services: Detects proxy/alias services like SimpleLogin, AnonAddy, Firefox Relay by analyzing MX records and domain patterns
- Provider-Specific Patterns: Recognizes common email forwarding services and their characteristics
- Domain Analysis: Examines domain structure, TLD patterns, and other signals
Result: May identify proxy services or provide hints about the email infrastructure.
Step 5: Login URL Retrieval
Once a provider is identified, the library retrieves the appropriate login URL:
- Pre-configured URLs: Each provider in the database has a verified HTTPS login URL
- Security Validation: All URLs are validated to ensure they:
- Use HTTPS protocol only
- Match allowlisted domains
- Pass malicious pattern detection (no IP addresses, URL shorteners, etc.)
- Are protected against injection attacks
Step 6: Response Formatting
The library returns a structured result object:
{
provider: {
companyProvider: "Gmail",
loginUrl: "https://mail.google.com/mail/"
},
email: "user@gmail.com",
detectionMethod: "domain_match",
// Extended mode includes additional metadata:
// - MX records analyzed
// - Detection timing breakdown
// - Provider metadata
}
Performance Characteristics
- Known domains: <1ms (instant database lookup)
- Business domains: 50-500ms (DNS MX record lookup)
- Unknown domains: Returns gracefully with helpful error information
- Rate limiting: Built-in protection prevents DNS query abuse
Why Use Email Provider Links?
❌ The Problem
- Users abandon registration flows when they can't find verification emails
- Generic "check your email" messages provide no helpful guidance
- Users don't know which email app to open or where to look
✅ The Solution
- Automatically detect the user's email provider
- Show provider-specific instructions and branding
- Provide direct "Go to Gmail" or "Check Outlook" buttons
- Reduce user confusion and improve completion rates
Benefits
Perfect For
🚀 User Registration
Guide new users directly to their inbox after they sign up, improving email verification completion rates.
🔐 Password Reset
Help users quickly find and access password reset emails by showing them exactly where to look.
📧 Email Verification
Reduce bounce rates in verification flows by providing clear, provider-specific guidance.
💼 Business Applications
Detect corporate email systems and provide appropriate messaging for business users.
Enterprise-Grade Security
All provider URLs must use HTTPS protocol
Only pre-approved domains are allowed (130+ verified providers)
Blocks IP addresses, URL shorteners, suspicious TLDs
Detects and blocks ../ and encoded variants
Prevents javascript:, data:, and script injections
SHA-256 hash verification for provider database
Get Started
📦 Installation
Install using npm:
npm install @mikkelscheike/email-provider-links
🛠️ Basic Usage
import { getEmailProvider } from '@mikkelscheike/email-provider-links';
const result = await getEmailProvider('user@gmail.com');
console.log(result);
// {
// provider: {
// companyProvider: 'Gmail',
// loginUrl: 'https://mail.google.com/mail/'
// },
// email: 'user@gmail.com',
// detectionMethod: 'domain_match'
// }
// With options (timeout and extended flag)
const resultExtended = await getEmailProvider('user@gmail.com', {
timeout: 5000,
extended: true
});
Built With Amazing Tools
⚡ Warp Terminal
Warp is the modern, AI-powered terminal that made this development process incredibly fast and efficient. With its intelligent command completion, AI assistance, and modern interface, Warp transformed how I interacted with the codebase.
🐙 GitKraken
GitKraken provided powerful Git visualization and management capabilities that streamlined our version control workflow. Its intuitive interface and advanced merge tools made managing the codebase seamless and efficient.