Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My email isn't getting through, how can I test the connection?

Testing email connections

My email isn't getting through, how can I test the connection?

by  cq  Posted    (Edited  )

If you are trying to send an email to someone and it isn't getting through, you usually receive an email back saying that your message cannot be delivered. Often it is not easy to determine where the problem lies.

This FAQ shows you how to test whether an email gateway is alive and responding properly. An email gateway can be thought of as the "drop box" for your email message. If your mail to user@test.com is delivered correctly to the email gateway then as far as your email program is concerned, the recipient has got the message.

The test method shown in this FAQ does not use any email application, it uses the "raw" mail commands.


Step 1 - determine the email gateway hostname

Every domain you can send email to (hotmail.com, gmail.com etc) has one or more MX records, which tell your email program or email server the hostname of the email gateway for that domain, i.e. where to send the message.

Let's say we're trying to send a message to user@hotmail.com. We need to find out what the mail gateway for hotmail.com is.

To do this, open a cmd window and type in

nslookup -type=mx hotmail.com

(Note, you do the lookup on the domain hotmail.com, not the email address user@hotmail.com)

You should get a result which lists the "mail exchanger" hosts. There may only be one, there may be multiple - my hotmail.com query brings up four:

hotmail.com MX preference = 5, mail exchanger = mx2.hotmail.com
hotmail.com MX preference = 5, mail exchanger = mx3.hotmail.com
hotmail.com MX preference = 5, mail exchanger = mx4.hotmail.com
hotmail.com MX preference = 5, mail exchanger = mx1.hotmail.com

Why four? For a public email server like Hotmail, it is sensible to have multiple potential mail gateways in case one or more are unavailable for any reason. Also in a high-use environment having multiple gateways provides a certain amount of load balancing.

As can be seen above, the four gateways are called mx1.hotmail.com, mx2.hotmail.com, mx3.hotmail.com, and mx4.hotmail.com.

So which one does your email program use? Well, it will use the "MX preference" number to decide. Gateways with a lower MX preference are tried first, higher MX preferences are only attempted if the lower gateways are unavailable. For hotmail.com, all four gateways have the same MX preference so your email program will choose one at random.


Step 2 - connect to the email gateway

So, you have the hostname of the email gateway you want to test. Remember if you have found multiple gateway hostnames, use one of the ones with the lowest MX preference; this is how your mail server behaves.

In your cmd window, type

telnet [gateway hostname] 25

So I would try "telnet mx1.hotmail.com 25"

If at this point, you get a "connect failed" message, either the mail gateway is down, or your firewall is blocking Port 25 which needs to be open for SMTP email. Try another domain's gateway, if this also fails then check your firewall.

A successful connection will reply with a string that begins with "220". Hotmail's mx1 host says this:

220 col0-mc2-f5.Col0.hotmail.com Sending unsolicited commercial or bulk e-mail t
o Microsoft's computer network is prohibited. Other restrictions are found at ht
tp://privacy.msn.com/Anti-spam/. Violations will result in use of equipment loca
ted in California and other states. Fri, 22 Jul 2011 02:01:55 -0700


The "220" at the beginning shows you are connected to the mail gateway.


You are now in a Telnet session with the remote mail gateway. To exit at any time type

quit



Step 3 - Further tests

Now it's time to talk to the gateway. Note that, depending on which operating system you are running, what you type may or may not be echoed to the screen. In other words, your typing may be invisible; it will still be present though.

In your Telnet cmd window type

ehlo [yourdomainname.com]

Here, "yourdomainname.com" is the end part of your email address; if you are alice@bobmail.com then you would put bobmail.com here.

The gateway should respond with a list of parameters like this:

250-snt0-mc3-f46.Snt0.hotmail.com (3.13.0.93) Hello [your IP address]
250-SIZE 36909875
250-PIPELINING
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-AUTH LOGIN
250-AUTH=LOGIN
250 OK

At this point, any number other than 250 at the beginning of each line indicates a problem. Google "SMTP 250" and you'll find a wealth of sites that explain the various code number meanings.
The "250 OK" at the end is telling you that the gateway is ready to talk further.
The other interesting parameter is "250 SIZE 36909875" - this is the maximum size in bytes that the mail gateway will accept. (Side note - due to encoding overheads, an email with an attachment typically expands by around 20%, so for you to send a 10MB email the mail gateway would have to have a message size limit of 12MB or more.)


Right, now let's continue.

In your Telnet session, type

mail from:[your email address]

The gateway should respond with something like

250 [your email address] Sender OK

Again, the "250" code here is good, it means that the mail gateway will accept emails from your address.

Now type

rcpt to:[recipient's email address]

The response will be something like

250 [recipient's email address] OK

The text of these replies differs between mail gateways, once again it is the '250' code that you are looking for.

If the gateway won't accept email for this recipient for any reason, you will get a message to this effect at this point. Note that the email can still fail at a later stage - for example, the mail gateway passes the email to the mail server, which errors because the recipient's mailbox is full - but here we are testing the mail gateway only.


Warning - if you continue with the next step you will actually send an email to your recipient - make sure this is OK before continuing!


Now type

data

And you should get a response starting with '354':

354 Ready for data.

Note Some email gateways are a bit picky at this point, and want more parameters to be sent information before allowing you to continue. But you've already proved the connection works, and the sender/recipient combination is OK.

Any text you type now will become the body of the email message.

Type <Enter> followed by a full stop (period) followed by <Enter> again and your message will be sent!


So, you can now tell if the mail gateway for your recipient is alive, whether it 'likes' your email address and whether it is OK delivering mail to the recipient. Any status codes differing from the normal ones given in this FAQ can be Googled which will hopefully pinpoint the problem.

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top