1. Library
  2. Email Protocols
  3. Routing

Updated 10 hours ago

Email relay and smart host configuration determine how mail servers send outbound messages. Instead of delivering directly to recipient servers, mail systems often route through intermediate servers that handle the hard parts—authentication, reputation management, and deliverability. Understanding relay architecture is essential for configuring reliable email infrastructure.

What Is Email Relay?

Email relay is the process of passing messages from one mail server to another. The term "relay" refers to any server that accepts a message and forwards it toward its destination, rather than delivering it to a local mailbox.

Every email traverses multiple relays:

  1. Your email client submits to your mail server (first relay)
  2. Your server forwards to an intermediate server (second relay, if configured)
  3. The message eventually reaches the recipient's mail server (final destination)

The question isn't whether to use relay—email always involves relaying. The question is how many hops and which servers should perform them.

Direct Delivery vs. Smart Host

Direct Delivery:

Your mail server looks up recipient domain MX records and connects directly to destination servers.

[Your Server] → [DNS MX Lookup] → [Recipient's Server]

Conceptually simple, but your server must:

  • Have a public IP with proper reverse DNS
  • Stay off spam blacklists
  • Handle MX lookup and retry logic
  • Maintain good IP reputation over time

Smart Host Relay:

Your mail server forwards all outbound mail to an intermediate "smart host" that handles final delivery.

[Your Server] → [Smart Host] → [Recipient's Server]

The smart host takes responsibility for MX lookup, retry logic, and actually reaching recipients.

What Is a Smart Host?

A smart host is a designated relay that your server uses for all outbound email. Instead of delivering directly, your server authenticates to the smart host and hands off messages.

Think of it as delegation. Your internal systems generate email, but a specialized system handles the complexity of Internet delivery—the reputation management, the ISP relationships, the blacklist monitoring, the retry strategies.

Common smart host scenarios:

ISP SMTP relay: Your Internet provider offers relay service (smtp.isp.com) for customers.

Cloud email service: SendGrid, Amazon SES, Mailgun, or SparkPost provide smart host relay with high deliverability.

Corporate mail server: Internal applications relay through a central server that handles external delivery.

Filtering service: Outbound messages route through a service that scans for spam and malware before delivery.

Why Use Smart Hosts?

IP Reputation:

Maintaining good IP reputation is surprisingly hard. Cloud smart hosts pool reputation across customers and handle ISP feedback loops, bounce processing, and blacklist monitoring professionally. One bad day of spam from a compromised account can destroy years of reputation building.

Port 25 Blocking:

Many ISPs block outbound port 25 to combat spam. Smart hosts accept connections on ports 587 or 465, bypassing these blocks.

Simplified Configuration:

Applications that generate email can relay to a smart host without implementing MX lookup, retry logic, SPF/DKIM signing, or error handling. The smart host does all of that.

Compliance:

Smart hosts can archive all outbound mail, apply data loss prevention policies, and enforce content filtering.

Deliverability:

Professional relay services optimize delivery timing, manage retry strategies, handle greylisting, and maintain relationships with major email providers. They know the quirks of Gmail, Yahoo, and Outlook.

Configuring Smart Host Relay

Most mail servers support smart host configuration. Setup requires:

  • Smart host address: The relay hostname (smtp.sendgrid.net, smtp.office365.com)
  • Port: Typically 587 (STARTTLS) or 465 (implicit TLS)
  • Authentication: Username/password or API keys
  • Encryption: TLS to protect credentials in transit

Postfix example:

# /etc/postfix/main.cf
relayhost = [smtp.sendgrid.net]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt

Authentication Methods

Smart hosts require authentication to prevent abuse:

Username and Password: Traditional authentication, often with app-specific passwords.

API Keys: Services like SendGrid provide keys that authenticate relay connections.

OAuth 2.0: Modern systems like Office 365 support token-based authentication.

IP-Based: Some smart hosts authenticate by source IP rather than credentials (less common now).

Certificate-Based: Mutual TLS using client certificates.

Always use encrypted connections when transmitting credentials.

Open Relay: The Cardinal Sin

Open Relay (Never Do This):

An open relay accepts mail from anyone and delivers it anywhere, without authentication. This was common in the early Internet but is now a critical security vulnerability.

An open relay is a megaphone anyone can grab. Within hours, spammers will find it and use your server's reputation to amplify their messages until your IP is blacklisted everywhere. Your ISP will likely suspend service.

Authenticated Relay (Always Do This):

Modern mail servers require authentication before accepting relay messages:

  • Require SASL authentication for relay
  • Require TLS before accepting credentials
  • Rate limit authenticated users to detect compromised accounts
  • Monitor for unusual sending patterns
  • Reject unauthenticated relay requests

Smart Host Providers

Cloud Email Services:

  • SendGrid — High-volume transactional email
  • Amazon SES — AWS-integrated, cost-effective
  • Mailgun — Developer-focused API
  • SparkPost — Analytics-rich platform
  • Postmark — Transactional specialist

Business Platforms:

  • Office 365 — Microsoft's cloud email
  • Google Workspace — Gmail for business

ISP Relay: Most providers offer SMTP relay for customers (smtp.comcast.net, smtp.att.net)

Relay Headers

Messages accumulate Received headers documenting each hop:

Received: from app-server.internal (unknown [192.168.1.10])
    by smarthost.example.com (Postfix) with ESMTPSA id ABC123
    for <recipient@destination.com>; Mon, 10 Dec 2025 14:30:00 -0500
Received: from smarthost.example.com (smarthost.example.com [203.0.113.50])
    by mail.destination.com (Postfix) with ESMTPS id DEF456
    for <recipient@destination.com>; Mon, 10 Dec 2025 14:30:05 -0500

Read from bottom to top: app-server submitted to smarthost, smarthost delivered to destination.

Conditional Relay

Some configurations use smart hosts selectively:

  • Route by domain: Send to @partner.com directly, relay others through smart host
  • Route by sender: Different applications use different smart hosts
  • Fallback: Attempt direct delivery, fall back to smart host on failure

Relay Restrictions

Mail servers should restrict relay carefully:

Postfix example:

smtpd_relay_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination

This permits relay from local networks or authenticated users, rejecting everyone else.

Troubleshooting

"Relay access denied": Server rejects unauthenticated relay. Configure credentials and verify authentication is enabled.

"Authentication failed": Wrong credentials or mechanism mismatch. Verify username, password, and that the smart host supports your auth method (PLAIN, LOGIN).

"Connection refused": Firewall blocking outbound connection. Check port (587 or 465) and firewall rules.

"TLS handshake failed": Certificate or protocol mismatch. Update TLS libraries and verify certificate validity.

"Rate limit exceeded": Sending too fast. Slow down, upgrade plan, or implement local queueing.

Monitoring Relay Health

Queue depth: Growing queues indicate delivery problems.

Bounce rates: High bounces suggest reputation or configuration issues.

Delivery latency: Delays may indicate relay performance problems.

Authentication failures: Log failures to detect credential problems or compromised accounts.

Frequently Asked Questions About Email Relay and Smart Hosts

Was this page helpful?

😔
🤨
😃
Email Relay and Smart Hosts • Library • Connected