Here is a simple and quick way to test a SMTP mail relay service.

Use the telnet program in unix or windows to connect to port 25(SMTP) on your
SMTP server.  Note that windows telnet from the command line will not echo what
you type so it is not recommended.

  telnet mail.yourdomain.com 25

You will be prompted with a SMTP server response something like this..

  Trying 64.26.21.198...
  Connected to mail.yourdomain.com.
  Escape character is '^]'.
  220 mail.yourdomain.com ESMTP Sendmail 8.9.3/8.9.3; Tue, 27 Aug 2002 16:20:32 -0500

Next you identify yourself with the ehlo "hello" command..

  ehlo myhost.mydomain.com

You should see a response like this..

  250-mail.yourdomain.com myhost.mydomain.com [203.32.9.6] pleased to meet you
  250-8BITMIME
  250-SIZE 10000000
  250-DSN
  250-ONEX
  250-ETRN
  250-XUSR
  250 HELP

Now start creating the mail message by entering the from address..  

  mail from: [email protected]

You will recieve a response like this..

  250 [email protected].. Sender ok

Now define the recipient's address..

  rcpt to: [email protected]
If the mail server allows relay for the user you specified, you will recieve
a resonse like this..

  250 [email protected].. Recipient ok

If the mail server does not allow relaying for the user specified, you will
an error like this..

  550 [email protected].. Relaying denied
This is a good way to test a mail server for the open relay vulnerability. If
the mail server allows relay for all email addresses and is publicly
accessable it may be used by spammers to send unsolicited mail.

Now we start the data part of the message, type...

  data

Next you need to construct the body of the message and optionaly nice looking
mail headers.  First the optional headers.  You can skip this step and still
send mail. When you are finished with the body of the message, type a single
"." on an otherwise empty line.  This will signal the end of the message.

  To: John Thomas <[email protected]>
  From: Jane Smith <[email protected]>
  Subject: Testing SMTP Mail Relay
  Dear John

  This is the body of the message.

  .

Now you will see a response like this..

  250 QAA07271 Message accepted for delivery
Finally, disconnect from the mail server by typing..

  quit

You will see..

  221 mail.yourdomain.com closing connection
  Connection closed by foreign host.
Optionaly you can continue to compose more messages.

Here is an end to end example...

user@host ~$ telnet 192.168.99.99 25
Trying 192.168.99.99...
Connected to mx.someotherplace.com (192.168.99.99).
Escape character is '^]'.
220 mx.someotherplace.com ESMTP CSEEMail (2.0)
ehlo myhost.org
250-mx.someotherplace.com
250-PIPELINING
250-SIZE 28672000
250-VRFY
250-ETRN
250 8BITMIME
mail from: [email protected]
250 Ok
rcpt to: [email protected]
250 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject: Howdy from me
here is the end to end test
.
250 Ok: queued as D3A30D80E1
quit
221 Bye
Connection closed by foreign host.
user@host ~$
Tags: , , ,
Leave a Reply