How to Configure MX Records for Specific Email Address Routing (e.g., me@mycompany.com)


2 views

Standard MX (Mail Exchange) records operate at the domain level, which means they can't natively route specific email addresses to different servers. When you want to redirect only me@mycompany.com to Server B while all other @mycompany.com addresses go to Server A, you need creative DNS and mail server configurations.

Option 1: Conditional Forwarding at Mail Server Level

The most reliable method is to:

  1. Set your primary MX record to point to your main mail server
    mycompany.com.    IN  MX  10 mail1.mycompany.com.
    mail1.mycompany.com. IN A 192.0.2.1
  2. Configure your primary mail server to forward specific addresses:

For Postfix example:

# /etc/postfix/transport
me@mycompany.com   smtp:[mail2.mycompany.com]
.*@mycompany.com   :

# /etc/postfix/main.cf
transport_maps = hash:/etc/postfix/transport

Option 2: Subdomain Routing (Advanced)

Create a subdomain MX record:

redirect.mycompany.com. IN MX 20 mail2.otherprovider.com.
me.mycompany.com.    IN CNAME redirect.mycompany.com.

Then configure your primary server to recognize the CNAME pattern.

Key factors to evaluate:

  • Mail server software capabilities (Postfix/Exchange/Sendmail)
  • SPF/DKIM/DMARC compatibility
  • Delivery latency for forwarded messages
  • Error handling when secondary server is unavailable

Essential diagnostic commands:

dig MX mycompany.com +short
telnet mail1.mycompany.com 25
swaks --to me@mycompany.com --server mail1.mycompany.com

MX (Mail Exchange) records operate at the domain level, not the individual email address level. When you set up MX records in your DNS, they apply to all emails under that domain (@mycompany.com). There's no native way in standard DNS to route specific email addresses (like me@mycompany.com) to different mail servers.

While you can't achieve this purely through MX records, here are practical workarounds:

1. Using SMTP Relay with Conditional Routing

Configure your primary mail server to act as a relay for specific addresses:

# Postfix configuration example (main.cf)
transport_maps = hash:/etc/postfix/transport

# /etc/postfix/transport content:
me@mycompany.com   smtp:[backup.server.com]:587
.mycompany.com     smtp:[primary.server.com]:25

2. Implementing Email Forwarding at DNS Level

Some advanced DNS providers offer email routing rules:

# Cloudflare Workers example for email routing
addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  if (request.headers.get('to') === 'me@mycompany.com') {
    return fetch('https://backup.server.com', request)
  }
  return fetch('https://primary.server.com', request)
}

For production environments, consider these professional approaches:

Microsoft 365 Mail Flow Rules

If using Exchange Online:

New-TransportRule -Name "RedirectSpecificUser" 
  -SentTo "me@mycompany.com" 
  -RouteMessageOutboundConnector "CustomBackupConnector"

Google Workspace Routing

In Google Admin Console:

1. Apps > Google Workspace > Gmail > Routing
2. Add new routing setting
3. Specify: "me@mycompany.com" in recipient list
4. Set alternate route to your backup server
  • SPF/DKIM/DMARC configuration must account for both servers
  • Message headers will show routing hops
  • Delivery delays may occur with complex routing
  • Maintain proper TLS certificates for all involved servers