Test Your SMTP Mail Server via Telnet

ProblemYou have configured an outgoing email server, and you want to make sure it's working correctly.

tl;dr

From command line/shell in any OS that has Telnet feature installed:

telnet mail.example.net 25 #this is your mail server
ehlo hostname.local #this is your computer's hostname, try to use a FQDN if you have one
mail from: support@example.net
rcpt to: support2@example.net
data
# type message here
# then hit Enter for a new line, type in "." (dot) and hit Enter again
.

Solution

Connect to Telnet in to your mail server on port 25 (SMTP). Keep in mind that backspace (<--) does not play well with Telnet. If you make a mistake, your best bet is to just hit enter and re-type in the command. Assuming your mail server's FQDN is mail.example.net:

telnet mail.example.net 25

This should give you your mail server's greeting, such as:

220 mail.example.net ESMTP Postfix

From there on, you need to introduce yourself via the helo or ehlo command:

ehlo hostname.mycomputer.net

Don't worry too much about your hostname. It is used by the mail server to determine where the email message is coming from, although the server has no way of verifying it. Even something like ehlo cat works fine. If the greeting was successful, you should see the server's list of options:

250-mail.example.net
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

Send a test message

From here you should be able to send a quick test message to make sure the server works. Generally, any off-the-shelf product such as Exchange or Zimbra will only allow you to send a message within your own domain, or with any email address, but only from an IP address within the same subnet. However, it works whether an email address exists or not. Try this:

mail from: 123test@example.net
rcpt to: support@example.net

Assuming the mailbox 123test@example.net is made up, but the mailbox support@example.net is real, the message should still show up in user Support mailbox. Now, type in data, followed by the actual message:

data
This is the first line of the email
This is the second line of the email

When you are done composing the message, hit Enter to create a new line, type in a "." (period), and hit Enter again to send it:

This is the last line of the email.
.

You should see a "message queued for delivery" notification:

250 2.0.0 Ok: queued as 88792103F48

From here, you should see the message in the user mailbox.

Relay access denied

If you try to send an email outside the allowed domains, or from an IP from which relaying (aka sending a message generated elsewhere) is not allowed, you may see a message similar to the ones below:

554 5.7.1 : Relay access denied

550 5.7.1 Unable to relay for steve.jobs@apple.com

This means you are trying to send a message outside the domain allowed by the server. This is done to prevent spam.


Was this article helpful?

mood_bad Dislike 5
mood Like 10
visibility Views: 34327