SMTP Tutorial 


Simple Mail Transfer Protocol
This tutorial is supposed to teach simple smtp commands and will allow you to see if your ISP blocks port 25.  Hopefully after this you will have a general knowledge of how SMTP works and will be able to impress your friends.  We will cover some more advanced stuff later.   SMTP is a very easy protocol to learn and once you know it you can use it in your scripts and everything else.  In the tutorial we will be using the windows telnet terminal.  If your on another OS, most of them have equivalents.  

Is your ISP blocking port 25?
Port 25 is the standard port used by smtp.  Many ISPs have started to block that port outside of their own system.  Why?  Spammers are under fire from every direction, if a ISP lets spam go out thru their doors, it is not good for them or their clients, the spam can clog their own systems and some people have tried to sue.  In order to protect themselves and their clients they have started blocking port 25, which keeps people connected thru them from connecting to any SMTP server but their own.  If you have a site that is with a web host, not your ISP, chances are that you have never been able to send email using your web host's smtp server.  If that is the case, your ISP have probably started blocking port 25.

Connecting to a smtp server:
Open your telnet program, in windows: click on the start button, select 'Run...' and type telnet into the box and press enter.  The standard telnet program should come up.

In the menu, select 'Connect', then 'Remote System...'.  The standard Connect box should come up and ask for three things: Host Name, Term Type, and Port.

Now press connect.  I will put server responses in red and your commands in blue.
First the server should say something like this

220 ESMTP Sendmail 8.9.3/8.9.0; Wed, 29 Dec 1999 14:10:55 -0800 (PST)

The main thing in all this are the numbers in front as those have to adhere to the standard.  If you receive a 220, you are fine.  When your typing, you won't be able to see any letters, so make sure you know what your typing. Now, you will want to type this:

ehlo me

Press enter.  ehlo is a hello command, me could be your name or whatever, it doesn't matter.  Some will say to use the helo command, ehlo is the newest incarnation of it, so use it.  The server should come back with something like: Hello [], pleased to meet you
250-SIZE 20000000
250 HELP 

Main thing is the 250, which indicates successful.  If you ever need to know a little more about some of the commands, issue the help command.  It should return a nice list of commands that you can use.  If you didn't get a 250, look at the error and see if you can correct it.  If your host requires you to check your mail before connecting to the smtp server, make sure and do that.  Now we will start our email by issuing the MAIL command, it will start the mail process.  Make sure you use real addresses so you can tell if it worked.

mail from:

Press enter.  

250 Sender ok

You should get a 250, address ok response.  That means that the from address is good.  Now we need to say who it is going to.  To do that you use the RCPT (recipient) command.

rcpt to:

Press enter.

250 Recipient ok

Again, you should get a 250.  Now we need to enter the rest of the message.  Type:


Press enter.

354 Enter mail, end with "." on a line by itself 

You should get a 354 response.  You can now type your message.  You have to include all the various headers that make the email look nice.  Otherwise, it will look like the email just appeared blankly from no sender.  So, type this stuff into the window:

To: Whoever <>
From: Your Name <>
Subject: The subject of the message
Your message should go here.
Type whatever you want, it doens't really make a difference

Now, we need to end the message, this is done by putting a single dot on a line and pressing enter.  Like this


250 OAA24319 Message accepted for delivery

The server should return a 250.  The message has been sent, unless you want to do some more mails, quit


Press enter

You should get a goodbye message and then connection lost to host..

Hopefully we will cover more in later chapters.