Kahibaro
Discord Login Register

5.3.5 Email routing concepts

Key Ideas in Email Routing

Email routing is about how MTAs (Mail Transfer Agents) decide where to send a message next, and how to get it there. In the Email Services section, you’ve seen components like SMTP, Postfix, and spam filtering; here we focus on the decision‑making and flow of messages between servers.

This chapter will use generic examples and some Postfix terms, but the configuration details of specific MTAs (like Postfix) belong in their own chapters.


Basic Message Flow and Roles

At a high level, an email may pass through several roles:

Routing concepts are mainly about what MTAs and MSAs do with a message: which next hop to choose, and how.


Addressing and Domains in Routing Decisions

Envelope vs. Header Addresses

Routing is based on the SMTP envelope, not the message headers:

Headers like From: or To: can be different and are mostly for display; routing logic cares about the envelope.

Local vs. Remote Domains

An MTA must distinguish between:

Routing rules typically begin with:

  1. Is the recipient domain local?
  2. If not, is it a relay domain?
  3. Otherwise, treat as remote and resolve via DNS.

DNS and MX in Email Routing

MX Records and Priority

For a domain like example.com, DNS may contain:

Key points:

Backup MX and Store‑and‑Forward

A backup MX is a secondary server with a higher preference value (numerically larger) that:

Routing considerations:

Inbound vs Outbound Routing

Inbound Routing (Mail Coming *Into* Your Domain)

Typical inbound path:

  1. Remote MTA looks up MX for yourdomain.tld.
  2. Sends mail to your MX (may hit load balancer, anti‑spam/AV gateway, etc.).
  3. Your MX decides:
    • If domain is local: hand to MDA (e.g., LMTP to Dovecot).
    • If domain is a relay target: forward to an internal mail server.

Important concepts:

Outbound Routing (Mail Going *Out* of Your Domain)

Outbound path:

  1. Users submit mail via MSA (auth on port 587 or 465).
  2. The MSA applies policies (authentication, authorization, rewriting).
  3. Outbound MTA chooses how to route:
    • Directly to recipient MX over the Internet.
    • Via a smarthost / relay (common in corporate or cloud environments).

Considerations:

Relaying and Open Relay Prevention

What Is Relaying?

Relaying = accepting mail where sender and recipient domains are not local and forwarding it on.

Example:

Legitimate scenarios:

Open Relay

An open relay is an MTA that:

Consequences:

Routing‑related protections:

Internal vs External Routing Topologies

Single Server

For small setups:

Edge/Hub Model

Common in medium/large organizations:

Routing examples:

Hybrid and Cloud Gateways

Organizations using hosted filtering / cloud email gateways (e.g. proofing or SaaS gateways):

Routing impacts:

Routing Based on Recipient and Sender

Recipient‑Based Routing

MTAs can select next hops based on:

These may use:

Sender‑Based Routing

Less common but useful:

Use cases:

Policy Routing and Security‑Driven Decisions

Routing is not only about “where,” but also “whether”:

Examples:

In complex environments, routing decisions may involve:

Alias, Forwarding, and Distribution Lists

These mechanisms influence routing within a domain:

Routing implications:

Special Routes: Smarthosts and Transport Maps

Smarthosts

A smarthost is an intermediary relay that all or some mail is sent through, regardless of the destination domain.

Uses:

Typical logic:

Targeted Transports

Transport rules allow fine‑grained routing for specific destinations:

This enables:

Loop Prevention and Bounce Handling

Loop Prevention

Misconfigured routing can create loops:

Mechanisms to avoid loops:

Bounces and Non‑Delivery Reports (NDRs)

When routing fails permanently:

Common routing‑related causes:

Good practice:

High Availability and Load Distribution in Routing

Routing is central to HA strategies:

Routing policies typically specify:

Putting It Together: Common Routing Patterns

Small Business Scenario

Corporate with Cloud Gateway

ISP/Hosting Provider

These patterns are all implementations of the same routing concepts: local vs remote domains, DNS lookups, explicit transport rules, and policy‑driven decisions.


By understanding these routing concepts—domains, MX records, local vs relay vs remote handling, smarthosts, policy‑based decisions, and loop prevention—you can design and troubleshoot complex email flows regardless of the specific MTA you use. Configuration details for Postfix, Dovecot, and others build directly on these fundamentals.

Views: 61

Comments

Please login to add a comment.

Don't have an account? Register now!