Skip to content

Why can't my server receive email after I created an MX record for my SMTP server in Route 53?

5 minute read
0

I configured a mail exchanger record (MX record) to route emails to my Simple Mail Transfer Protocol (SMTP) server in Amazon Route 53. However, my server doesn't receive email.

Resolution

Check your public hosted zone's resource record sets

Verify that your Route 53 public hosted zone has the required resource record sets.

Configure your domain registrar's name servers to use the Route 53 name server

If you use Route 53 for DNS services with a different domain registrar, then look up your domain name in the WHOIS tool. The results show your domain registrar and current authoritative name servers. To use WHOIS, see WHOIS domain lookup on the WHOIS website.

Important: If the name servers don't match your Route 53 public hosted zone name servers, then DNS queries for your SMTP server aren't directed to Route 53.

If your name server doesn't match your Route 53 public hosted zone name servers, then complete the following steps:

  1. Enter your registrar name in the WHOIS utility's query field, and then choose the Registrar option to find the contact information for your domain registrar.
    You can run the following whois command:

    whois YOUR_DOMAIN_NAME | grep 'Name Server'

    Note: Replace YOUR_DOMAIN_NAME with your domain name.

  2. Ask your domain registrar to update the name server list so that your domain references the name servers in your Route 53 public hosted zone.

  3. Verify that your previous DNS service maintains the resource record sets during the TTL (time to live) period.

Wait for the name server TTL period to expire for Route 53 to respond to DNS queries. For more information, see I changed DNS settings, but they haven't taken effect.

Check for DNS MX record set issues

Run the following Windows, Linux, or macOS command to check whether an MX record for the domain exists to route email to your SMTP server.

Command for Linux or macOS operating system (OS):

dig DOMAIN_NAME MX

Example output:

$ dig amazon.com MX
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.amzn2.2 <<>> amazon.com MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61726
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;amazon.com.                    IN      MX

;; ANSWER SECTION:
amazon.com.             300     IN      MX      5 amazon-smtp.amazon.com.
;; Query time: 1 msec
;; SERVER: 10.10.0.2#53(10.10.0.2)
;; WHEN: Wed Apr 14 06:21:43 UTC 2021
;; MSG SIZE  rcvd: 67

Command for Windows OS:

nslookup -type=MX DOMAIN_NAME

Example output:

$ nslookup -type=MX amazon.comServer:         10.10.0.2
Address:        10.10.0.2#53

Non-authoritative answer:
amazon.com      mail exchanger = 5 amazon-smtp.amazon.com.

Then, run the following Windows, Linux, or macOS command to confirm that you can resolve the MX record hostname.

Command for Linux or macOS:

dig MX_RECORD

Example output:

$ dig amazon-smtp.amazon.com
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.amzn2.2 <<>> amazon-smtp.amazon.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64180
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;amazon-smtp.amazon.com.                IN      A

;; ANSWER SECTION:
amazon-smtp.amazon.com. 27      IN      A       52.94.124.7

;; Query time: 1 msec
;; SERVER: 10.10.0.2#53(10.10.0.2)
;; WHEN: Wed Apr 14 06:41:18 UTC 2021
;; MSG SIZE  rcvd: 67

Command for Windows OS:

nslookup MX_RECORD

Example output:

$ nslookup amazon-smtp.amazon.comServer:         10.10.0.2
Address:        10.10.0.2#53

Non-authoritative answer:
Name:   amazon-smtp.amazon.com
Address: 52.119.213.154

Note: For MX records, Route 53 uses a different syntax from other DNS providers. To effectively route your email, keep the record set name blank when you create a root domain MX record in Route 53. Also, don't add the at (@) character or other characters, even though some DNS providers require the at (@) character before the MX record set name.

Test email delivery

Complete the following steps:

  1. Run the following command, and then press Enter:

    telnet MAIL_SERVER_NAME_OR_IP MAIL_SERVER_PORT_NUMBER

    Note: Replace MAIL_SERVER_NAME with your mail server name, IP MAIL_SERVERwith your IP address, and PORT_NUMBER with your port number. If you make a typographical error, then press Enter and retry the command. If the command doesn't work after you press Enter, then close the telnet session and reconnect.

  2. Run the following command, and then press Enter:

    EHLO YOUR_MAIL_SERVER_FULLY_QUALIFIED_DOMAIN_NAME
    

    Note: Replace YOUR_MAIL_SERVER_FULLY_QUALIFIED_DOMAIN_NAME with your mail server domain name.

  3. Run the following command, and then press Enter:

    mail from: your_name@yourdomainname

    Note: Replace your_name@yourdomainname with your email address.
    The server responds with 250 OK.

  4. Run the following command, and then press Enter:

    rcpt to: recipient@yourdomainname

    Note: Replace recipient@yourdomainmame with the recipient's email address. The sender and recipient can have the same email address.

    Important: If the server verifies the sender and recipient's email address, then the server responds with 250 Accepted.

  5. Run the following command, and then press Enter:

    data
  6. Run the following command, and then press Enter:

    Subject: SPECIFY_SUBJECT_HERE
  7. Run the following command, and then press Enter:

    SPECIFY_MESSAGE_HERE
  8. Run the following command, and then press Enter:

    .

    The server accepts the message for delivery and responds with 250 OK to confirm that it sent the email.

If your SMTP server still can't receive email after you verify the MX record configuration, then contact your email service provider.