Email Address Validation
The validate command checks if email addresses are likely deliverable before you send emails. This helps prevent bounce-backs and improves email deliverability.
Overview
Email validation performs several checks to determine if an email address can receive messages:
- Syntax validation - Checks if the email format is valid (RFC 5322 compliant)
- Domain validation - Verifies the domain exists via DNS lookup
- MX record check - Confirms the domain has mail server records configured
- SMTP verification (optional) - Attempts to verify with the mail server directly
Basic Usage
# Validate a single email address
mailos validate [email protected]
# Validate multiple email addresses
mailos validate [email protected] [email protected] [email protected]
# Using the --email flag (can be repeated)
mailos validate --email [email protected] --email [email protected]Command-Line Flags
Basic Options
| Flag | Short | Type | Default | Description | Example |
|---|---|---|---|---|---|
--email | -e | []string | Email address(es) to validate (can be repeated) | mailos validate --email value |
Advanced Options
| Flag | Short | Type | Default | Description | Example |
|---|---|---|---|---|---|
--full | bool | false | Perform full validation including SMTP check (slower) | mailos validate --full | |
--quick | bool | false | Perform quick validation (syntax + MX only) | mailos validate --quick |
Output Options
| Flag | Short | Type | Default | Description | Example |
|---|---|---|---|---|---|
--json | bool | false | Output results as JSON | mailos validate --json | |
--verbose | -v | bool | false | Show detailed validation information | mailos validate --verbose |
Command Flags
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--email | -e | string[] | Email address(es) to validate (can be repeated) | |
--verbose | -v | bool | false | Show detailed validation information |
--json | bool | false | Output results as JSON | |
--full | bool | false | Perform full validation including SMTP check (slower) | |
--quick | bool | false | Perform quick validation (syntax + MX only) |
Examples
Basic Validation
$ mailos validate [email protected]
Email Address Validation Results
================================
Checked at: 2025-01-15 10:30:45
[email protected]
--------------------------------
Summary: 1 valid, 0 invalidVerbose Output
$ mailos validate [email protected] [email protected] --verbose
Email Address Validation Results
================================
Checked at: 2025-01-15 10:30:45
[email protected]
Syntax: OK | Domain: OK | MX: OK
Mail servers: in1-smtp.messagingengine.com, in2-smtp.messagingengine.com
Details: Email address appears to be valid and deliverable
[email protected] - Domain does not exist
Syntax: OK | Domain: FAIL | MX: FAIL
Details: The domain 'nonexistent-domain.xyz' could not be found. DNS lookup failed.
--------------------------------
Summary: 1 valid, 1 invalidJSON Output
$ mailos validate [email protected] --json[
{
"email": "[email protected]",
"is_valid": true,
"syntax_valid": true,
"domain_valid": true,
"mx_valid": true,
"deliverable": true,
"details": "Email address appears to be valid and deliverable",
"mx_records": ["gmail-smtp-in.l.google.com", "alt1.gmail-smtp-in.l.google.com"],
"checked_at": "2025-01-15T10:30:45Z"
}
]Full SMTP Validation
For more thorough validation, use the --full flag which attempts to connect to the mail server:
$ mailos validate [email protected] --full --verboseNote: SMTP verification can be slow and may be blocked by some mail servers. Many servers reject verification attempts for security reasons, so a failed SMTP check doesn't necessarily mean the address is invalid.
Integration with Send Command
Email validation is automatically enabled when sending emails. The send command will validate all recipients before attempting to send.
# Validation happens automatically (enabled by default)
mailos send --to [email protected] --subject "Hello" --body "Hi there"
# Skip validation if needed
mailos send --to [email protected] --subject "Hello" --body "Hi there" --no-validate
# Force send even if validation fails
mailos send --to [email protected] --subject "Hello" --body "Hi there" --force
# Enable SMTP verification during send
mailos send --to [email protected] --subject "Hello" --body "Hi there" --validate-smtpSend Command Validation Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--validate | bool | true | Validate recipient email addresses before sending |
--no-validate | bool | false | Skip email address validation |
--validate-smtp | bool | false | Perform SMTP verification during validation (slower) |
Validation Results
Valid Email
When an email passes all checks:
- Syntax is correct
- Domain exists and resolves
- MX records are configured
- (Optional) SMTP server accepts the address
Invalid Email - Common Errors
| Error | Description |
|---|---|
Invalid email syntax | Email format doesn't match RFC 5322 standards |
Domain does not exist | DNS lookup failed - domain may not exist or has expired |
No mail server found | Domain has no MX records - cannot receive email |
Recipient rejected | SMTP server explicitly rejected the address (full mode only) |
Use Cases
Pre-Send Validation
Validate a list of recipients before a bulk send:
# Validate all recipients first
mailos validate [email protected] [email protected] [email protected]
# If all valid, proceed with send
mailos send --to [email protected],[email protected],[email protected] --subject "Newsletter" --file newsletter.mdScripting and Automation
Use JSON output and exit codes for automation:
# Check exit code (0 = all valid, non-zero = some invalid)
if mailos validate [email protected] --json > /dev/null 2>&1; then
echo "Email is valid"
else
echo "Email is invalid"
fi
# Parse JSON output for detailed results
mailos validate [email protected] --json | jq '.[] | select(.deliverable == false)'Cleaning Email Lists
Validate a list of emails and filter out invalid ones:
# Read emails from file, validate, and output valid ones
cat emails.txt | xargs mailos validate --json | jq -r '.[] | select(.deliverable) | .email'Performance Notes
- Quick mode (
--quick): Fastest, checks syntax and MX records only (~100ms per email) - Default mode: Balanced, includes domain DNS verification (~200-500ms per email)
- Full mode (
--full): Most thorough, includes SMTP verification (~1-5 seconds per email)
For bulk validation, consider using quick mode and only using full validation for critical addresses.
Limitations
- SMTP verification is not definitive - Many mail servers block verification attempts or give false positives/negatives
- Catch-all domains - Some domains accept all addresses even if the mailbox doesn't exist
- Temporary failures - DNS or network issues can cause false negatives
- Rate limiting - Validating too many emails quickly may trigger rate limits
