Powered by Invision Power Board


  Reply to this topicStart new topicStart Poll

> Testing your SMTP Server, ...and how to send headers
fishsponge
Posted: May 7 2003, 10:35 AM
Quote Post


Administrator
********

Group: Admin
Posts: 679
Member No.: 1
Joined: 13-February 03



Ever wondered why your SMTP server isn't working? or wondered whether it's open-relay or not? well a good test is to telnet into it and send a few emails manually to different addresses. a comprehensive test is to send emails from:

remote machine -> mail server -> local user on mail server

remote machine -> mail server -> remote email address

local machine -> mail server -> local user on mail server

local machine -> mail server -> remote email address

If your mail server is open relay, then all of these will be allowed... if you are only allowing email to be sent from certain hosts, then the second one of the four should fail. More may fail too, but only if you have more security rules applied.

To test you mail server manually, here are the commands taken from an example done on my machine at home (this is a test of sending from a local machine -> remote email address):
CODE
bash-2.05$ telnet turnip 25
Trying 192.168.254.101...
Connected to turnip.
Escape character is '^]'.
220 turnip ESMTP Exim 3.35 #1 Wed, 07 May 2003 11:27:45 +0100
HELO eMonster
250 turnip Hello emonster [192.168.254.100]
MAIL From:<unixforum@mongeese.co.uk>
250 <unixforum@mongeese.co.uk> is syntactically correct
RCPT To:<test@unixforum.co.uk>
250 <test@unixforum.co.uk> is syntactically correct
DATA
354 Enter message, ending with "." on a line by itself
This is a test email

From,
Richard (fishsponge)
.
250 OK id=19DMAH-0003tv-00
^]
telnet> quit
Connection to turnip closed.
bash-2.05$

This mail was accepted for delivery because my mail server allows relaying to external hosts if the email is sent from a local machine on my LAN. The commands you need to type into the mail server are fairly simple:

1. First of all, telnet into the mail server on the correct port by typing telnet <mailserver> 25:
CODE
bash-2.05$ telnet turnip 25
Trying 192.168.254.101...
Connected to turnip.
Escape character is '^]'.
220 turnip ESMTP Exim 3.35 #1 Wed, 07 May 2003 11:27:45 +0100

2. Then introduce yourself as the machine you are logging in from by typing HELO <hostname>:
CODE
HELO eMonster
250 turnip Hello emonster [192.168.254.100]

3. Next, specify which address the email is going to be from by typing MAIL From:<name@domain.com>:
CODE
MAIL From:<unixforum@mongeese.co.uk>
250 <unixforum@mongeese.co.uk> is syntactically correct

4. You then need to say who the email is going to be delivered to by typing RCPT To:<name@domain.com>. NOTE: You can run this command several times for each email address:
CODE
RCPT To:<test@unixforum.co.uk>
250 <test@unixforum.co.uk> is syntactically correct

5. Then you need to type DATA to enter the actual email body.
CODE
DATA
354 Enter message, ending with "." on a line by itself
This is a test email

From,
Richard (fishsponge)
.
250 OK id=19DMAH-0003tv-00

this will then add the email to the message queue on the mail server. You can view messages that have not yet been sent by logging into the mail server, and running the mailq command as root.

Now... as part of the DATA entry, you can include the email headers too (such as the "To:", "From:" and "Subject:" fields)... here's how:

Once you type the DATA command, enter text like the following:
CODE
DATA
354 Enter message, ending with "." on a line by itself
To: "Hobbs, Richard" <webmaster@unixforum.co.uk>
From: "Test User" <webmaster@unixforum.co.uk>
Subject: This is a test
This is the first line of the body of the email...
This is the second line...
etc...
.
250 OK id=19k2rZ-0000zz-00

(remember to end the email data with a single dot ( . ) on a line by itself)

When the email with the headers is received it'll look like this:
CODE
Date:    Tue, 05 Aug 2003 15:33:25 +0100
From:    Test User <webmaster@unixforum.co.uk>
To:      "Hobbs, Richard" <webmaster@unixforum.co.uk>
Subject: This is a test

This is the first line of the body of the email...
This is the second line...
etc...

instead of this:
CODE
Date:    Tue, 05 Aug 2003 15:33:25 +0100
From:    Test User <webmaster@unixforum.co.uk>
To:
Subject:

This is the first line of the body of the email...
This is the second line...
etc...
PMEmail PosterUsers WebsiteICQAOLYahooMSN
Top
fishsponge
Posted: Aug 5 2003, 02:28 PM
Quote Post


Administrator
********

Group: Admin
Posts: 679
Member No.: 1
Joined: 13-February 03



Oh, and here's how to send a dot ( . ) on a new line without ending the DATA field of your email!

The problem with sending a dot on a line by itself is the following:
CODE
hobbs@turnip:~$ telnet turnip 25
Trying 192.168.254.101...
Connected to turnip.
Escape character is '^]'.
220 turnip ESMTP Exim 3.35 #1 Tue, 05 Aug 2003 15:20:39 +0100
EHLO turnip
250-turnip Hello hobbs at turnip [192.168.254.101]
250-SIZE
250-PIPELINING
250 HELP
MAIL From:<webmaster@unixforum.co.uk>
250 <webmaster@unixforum.co.uk> is syntactically correct
RCPT To:<webmaster@unixforum.co.uk>
250 <webmaster@unixforum.co.uk> is syntactically correct
DATA
354 Enter message, ending with "." on a line by itself
.      
250 OK id=19k2i5-0000Ut-00

As you can see, once you type "DATA" to begin entering the headers and body of the email it tells you to enter a dot on a line by itself to end the input, and send the email. The email above (when received) looks like this:
CODE
Date:    Tue, 05 Aug 2003 15:24:53 +0100
From:    webmaster@unixforum.co.uk
Subject:

What if you want a dot on a line by itself to be an actual part of the email though??

what you need to do is enter two dots on the line instead of one...
CODE
hobbs@turnip:~$ telnet turnip 25
Trying 192.168.254.101...
Connected to turnip.
Escape character is '^]'.
220 turnip ESMTP Exim 3.35 #1 Tue, 05 Aug 2003 15:25:36 +0100
EHLO turnip
250-turnip Hello hobbs at turnip [192.168.254.101]
250-SIZE
250-PIPELINING
250 HELP
MAIL From:<webmaster@unixforum.co.uk>
250 <webmaster@unixforum.co.uk> is syntactically correct
RCPT To:<webmaster@unixforum.co.uk>
250 <webmaster@unixforum.co.uk> is syntactically correct
DATA
354 Enter message, ending with "." on a line by itself
..
..
..
.
250 OK id=19k2l4-0000eY-00

this then sends an email that looks like this:
CODE
Date:    Tue, 05 Aug 2003 15:25:54 +0100
From:    webmaster@unixforum.co.uk
Subject:

.
.
.

sorted! :D
PMEmail PosterUsers WebsiteICQAOLYahooMSN
Top
Mango
Posted: May 2 2004, 06:14 PM
Quote Post


Newbie
*

Group: Members
Posts: 1
Member No.: 273
Joined: 2-May 04



Additionally, if you would like two dots on a line by themselves, enter ...

Three dots is .... and so on.
PMEmail Poster
Top
fishsponge
Posted: May 5 2004, 04:10 PM
Quote Post


Administrator
********

Group: Admin
Posts: 679
Member No.: 1
Joined: 13-February 03



indeed :D
PMEmail PosterUsers WebsiteICQAOLYahooMSN
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | Tutorials & How-To's | Next Newest »

Topic Options Reply to this topicStart new topicStart Poll

 



[ Script Execution time: 0.1859 ]   [ 12 queries used ]   [ GZIP Enabled ]




Partners: Cambridge Plus :: <Link Available> :: PCB Layout Bedfordshire :: <Link Available>
Unix Man Pages / Linux Man Pages :: HiFi Forum :: SIP VoIP Phone & Provider Reviews :: UNIX/Linux Forum Archives

More info on advertising on Unix/Linux Forum