Telnet - SMTP Commands (sending mail using telnet)
Telnet from your computer to the mail server.
$ telnet mailhost.westhawk.co.uk smtp
You should receive a reply like:
Trying 192.168.4.187...
If the last line is made of lots of stars with an occasional 2 or 0 then you are probably going through a Cisco PIX, and
none of the extended commands will work.
Connected to mailhost.domain.co.uk.
Escape character is '^]'.
220 way.domain.co.uk ESMTP Sendmail 8.11.6/8.11.6; Wed, 30 Jul 2003 12:27:39 +0100
You will then need to declare where you are sending the email from. You can use either standard or extended SMTP
commands to do this. Extended commands allow you to see what is supported by the server and to authorize yourself:
| Standard SMTP |
|---|
HELO local.domain.nameThis should give you:
250-way.domain.co.uk Hello mailhost.domain.co.uk [192.168.4.187], pleased to meet you
|
| Extended SMTP |
EHLO local.domain.nameThis should give you:
250-way.westhawk.co.uk Hello mailhost.domain.co.uk [192.168.4.187], pleased to meet youIf "AUTH" is listed you can login to the server. This will usually allow some things which are normally restricted, for example relaying. You will need to use your username and password in Base64 (See here for an encoder). AUTH LOGIN 334 VXNlcm5hbWU6 bmFtZQ== 334 UGFzc3dvcmQ6 U2VjcmV0 235 2.0.0 OK Authenticated |
Dont worry too much about your local domain name although you really should use your exact fully qualified domain name as seen by the outside world the mail server has no choice but to take your word for it as of RFC822-RFC1123.
Now give your email address:
MAIL FROM: <mail@domain.ext>
The angle brackets around the name are important; some servers won't accept the name unless they are there.
Should yield:
250 2.1.0 mail@domain.ext... Sender ok
Now give the recipients address:
RCPT TO: <mail@otherdomain.ext>
Again, use the angle brackets.
Should yield:
250 2.1.0 mail@otherdomain.ext... Recipient ok
To start composing the message issue the command:
DATA
Subject:-type subject here-
then press enter twice (these are needed to conform to RFC 882)
You may now proceed to type the body of your message on as many lines as it takes. To tell the mail server that you have
completed the message enter a single "." on a
line by itself.
The mail server should reply with:
250 2.0.0 ???????? Message accepted for delivery
You close the connection by issuing:
QUIT
The mailserver should reply with something like:
221 2.0.0 mailhost.domain.co.uk closing connection
Connection closed by foreign host.

