Using nslookup, telnet, ping to troubleshoot email issues

It is essential to have proper DNS entries for your email infrastructure. I have seen many misconfigured DNS system causing the entire mail system to go bad. Some serious scenarios include:

  • Mail server being blacklisted
  • Mail server has bad reputation causing email sent from that server to be bounced (unaccepted by other mail servers).
  • Mail loss leading to business loss.

In assisting the administrator to troubleshoot email issues, I have included here a few command-line tools such as NSLOOKUP, TELNET, and PING for your references.

Ping to verify a host (A) record. We need to verify that a host (A) record exists for email. This host record should potentially be placed in the MX record section as well. Ping and ensure that the record returns an IP address. You may not get a reply from the ping as the administrator might have blocked pinging on the firewall.

NSLOOKUP to verify forward host (A) record. Instead of pinging, we can use the NSLOOKUP command to find out the IP address of the host record. This host record – as mentioned before – should be placed in the MX record section.

In the example below, I try to look up the record using the Google’s DNS server (

Note that I did not have to type at the end and the result would be the same. This is because my Primary DNS server is actually as set in the system.

Suppose I would like to use as the DNS Server to test my NSLOOKUP, I can do so by typing:


NSLOOKUP to verify reverse (PTR) record. PTR record is called a reversed DNS record that points an IP address to a host record. This host record should be placed in your MX record database. In the example below, nslookup cannot locate a PTR record for the IP address


Let’s perform a reverse lookup for another IP address to see if it exists:



Verify MX records. Using nslookup, we can verify the existence of the MX records for a domain using the set q=mx statement.

We can also use nslookup –query=mx to check for MX record,


Verify SPF record. SPF records are TXT records that mail servers use to validate the source of email. It is nowadays essentials to have SPF record configured correctly for your mail server in order to avoid potential problems for email flow.

nslookup # this will use our system DNS server which is in my case

server # this will change the DNS server to

set type=txt # check SPF record # check SPF record for


How to use Telnet to test SMTP server

Step 1) Use nslookup to find out what the MX records for a domain are. There might be multiple MX records for backup reasons. In the example below, there are five MX records for the domain The one with highest priority is Should this host goes down, the next prioritized one, which is will receive mail on behalf of the failed server.

Use TELNET to telnet into port 25 of the mail server. In this case, I choose the second prioritized server to access.

telnet smtp

Issue the HELO command:


Issue the mail from command

mail from:

Issue the rcpt to: command

Example: rcpt to:

Issue the data command

Now enter the email from, to, subject, and body. Enter a period (.) when done.

Type quit to exit TELNET.

Check Email to verify that we receive the test email.

That’s it!