Introducing PostScale -- email API for transactional, inbound, and masked addresses. PostScale

    What Is an MX Record

    Learn how MX records direct email to the right mail servers, including priority settings. Includes examples for the DNScale dashboard and API.

    An MX (Mail Exchange) record specifies which mail servers are responsible for receiving email for your domain. When someone sends an email to user@yourdomain.com, MX records tell the sending server where to deliver the message.

    How MX Records Work

    MX records include two key components:

    1. Priority (preference) - A number indicating server priority (lower = higher priority)
    2. Mail server - The hostname of the mail server
    example.com.    3600    MX    10 mail.example.com.
    example.com.    3600    MX    20 backup.example.com.

    When sending an email to user@example.com:

    1. Sender's mail server queries MX records for example.com
    2. Tries the server with lowest priority (10 = mail.example.com) first
    3. If unavailable, falls back to higher priority servers (20 = backup.example.com)

    Common Use Cases

    Single Mail Server

    Basic setup with one mail server:

    example.com.    3600    MX    10 mail.example.com.

    Multiple Mail Servers with Failover

    Primary and backup servers:

    example.com.    3600    MX    10 mail1.example.com.
    example.com.    3600    MX    20 mail2.example.com.
    example.com.    3600    MX    30 mail3.example.com.

    Third-Party Email Services

    Google Workspace:

    example.com.    3600    MX    1  aspmx.l.google.com.
    example.com.    3600    MX    5  alt1.aspmx.l.google.com.
    example.com.    3600    MX    5  alt2.aspmx.l.google.com.
    example.com.    3600    MX    10 alt3.aspmx.l.google.com.
    example.com.    3600    MX    10 alt4.aspmx.l.google.com.

    Microsoft 365:

    example.com.    3600    MX    0  example-com.mail.protection.outlook.com.

    Zoho Mail:

    example.com.    3600    MX    10 mx.zoho.eu.
    example.com.    3600    MX    20 mx2.zoho.eu.
    example.com.    3600    MX    50 mx3.zoho.eu.

    Load Balancing

    Equal priority distributes load:

    example.com.    3600    MX    10 mail1.example.com.
    example.com.    3600    MX    10 mail2.example.com.
    example.com.    3600    MX    10 mail3.example.com.

    Record Format

    FieldDescriptionExample
    NameDomain (usually apex)@ (apex), subdomain
    TypeRecord typeMX
    PriorityServer preference (lower = preferred)10
    ContentMail server hostnamemail.example.com.
    TTLTime to live (seconds)3600

    Adding an MX Record

    Using the Dashboard

    1. Navigate to your zone in the DNScale dashboard
    2. Click Add Record
    3. Configure the record:
      • Name: Usually @ for the apex domain
      • Type: Select MX
      • Priority: Enter the priority value (e.g., 10)
      • Value: Enter the mail server hostname
      • TTL: Set the cache duration (default: 3600)
    4. Click Create Record

    Using the API

    Create an MX record:

    curl -X POST "https://api.dnscale.eu/v1/zones/{zone_id}/records" \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "@",
        "type": "MX",
        "content": "mail.example.com",
        "ttl": 3600,
        "priority": 10
      }'

    Set up Google Workspace MX records:

    # Primary MX
    curl -X POST "https://api.dnscale.eu/v1/zones/{zone_id}/records" \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "@",
        "type": "MX",
        "content": "aspmx.l.google.com",
        "ttl": 3600,
        "priority": 1
      }'
     
    # Secondary MX
    curl -X POST "https://api.dnscale.eu/v1/zones/{zone_id}/records" \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "@",
        "type": "MX",
        "content": "alt1.aspmx.l.google.com",
        "ttl": 3600,
        "priority": 5
      }'

    API Response:

    {
      "status": "success",
      "data": {
        "message": "Record created successfully",
        "record": {
          "id": "encoded-record-id",
          "name": "example.com.",
          "type": "MX",
          "content": "mail.example.com.",
          "ttl": 3600,
          "priority": 10,
          "disabled": false
        }
      }
    }

    Best Practices

    1. Always have backup MX servers - Use multiple MX records with different priorities for redundancy

    2. Use appropriate priority gaps - Leave room between priorities (10, 20, 30) to insert new servers later

    3. MX targets must be A/AAAA records - MX records should point to hostnames with A/AAAA records, not CNAMEs

    4. Configure reverse DNS - Ensure your mail servers have proper PTR records for deliverability

    5. Add SPF, DKIM, and DMARC - Complement MX records with email authentication records

    Email Authentication Records

    MX records work alongside other records for email security:

    Record TypePurpose
    MXDirects incoming mail
    TXT (SPF)Authorizes sending servers
    TXT (DKIM)Email signing verification
    TXT (DMARC)Policy for failed authentication

    Example complete email setup:

    example.com.    3600    MX     10 mail.example.com.
    example.com.    3600    TXT    "v=spf1 mx -all"
    example.com.    3600    TXT    "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com"

    Testing MX Records

    Verify your MX records with dig:

    dig MX example.com
     
    # Check specific nameserver
    dig MX example.com @ns1.dnscale.eu

    Or use online tools like MXToolbox to verify your email configuration.

    • TXT - SPF, DKIM, DMARC records
    • A - Mail server IP addresses
    • PTR - Reverse DNS for mail servers

    Conclusion

    MX records are the foundation of email delivery for your domain. Proper configuration with backup servers, appropriate priorities, and complementary authentication records ensures reliable and secure email communication. DNScale makes managing MX records straightforward, whether you're self-hosting mail or using a third-party provider.