# How to send mail via telnet to a server using SMTP commands

# Sending an e-mail via Telnet

In this document, we:

- shall use Telnet to connect to the SMTP server.
- shall give commands to the server, then type our e-mail, and finally tell the server, 'Okay, the e-mail is done. Send it.
- can then send more mails, or disconnect from the server.

## Connect

`telnet mail.monitortools.com 25`

This will open a Telnet window, and within a short time, you will be connected to the SMTP server, and the server says:

`220 PROTAGONISTNT Mailmax version 4. 8. 3. 0 ESMTP Mail Server Ready`

This varies, but you should definitely see the '220' part. It is an indication that the server is ready to service your request.

## Handshake

Now the server expects you to identify yourself. You can enter the name of your computer or anything else you want. If you have a domain-name, then you should enter the domain-name here. My computer's name is dell01, so I say:

`helo dell01`

Note that it is 'helo' and not 'hello'. The commands are not case-sensitive, so you can also say HeLo or HELO or hELo. The server replies:

`250 HELO 217.120.215.201, How can I help you?`

This is like a shake-hand. You tell the server your name, and it says its name! Computers are quite friendly, you see!

## From

Next give the server your e-mail address. **Note that most SMTP servers require that your e-mail address belong to the same domain as the server.** For example, if you send mail from Yahoo! SMTP server, you should have a Yahoo! address. You cannot use it if you give it a Hotmail address. Let me give the SMTP server some e-mail address:

`mail from: webmaster@monitortools.com`

'mail from:' is a SMTP command. Note that there is a space between 'mail' and 'from', followed by a colon (:). The server says:

`250 Ok`

## To

Tell the server who you want to send the e-mail to. Let me send a mail to info@activexperts:

`rcpt to: info@activexperts.com`

There are no restrictions here. You can enter any e-mail address. If there is some problem with the recipient-address, your mail will bounce, but for now, the server doesn't complain. It will say:

`250 Ok`

## Body

You have told the server your e-mail address, and the recipient's e-mail address, so now you can go ahead and type the e-mail. You have to do that with the data command:

`data`

The server asks you to go ahead with your e-mail:

`354 End data with .`

## Send

Now type in your e-mail, like this:

`This is a test e-mail.`  
`Remember to type it all right. Backspace key doesn't work in Windows`  
`Telnet, though it does in Linux. If you make a mistake, try pressing`  
`CTRL-h. If it works, well and good.`

When you finish your e-mail, press \[ENTER\], then a '.', and again an \[ENTER\]. This tells the server that you have finished the e-mail, and it can send it. It will say:

`250 Ok: queued as 6AB5150038`

Your mail was sent!

## Disconnect

Now you can either send another mail, or disconnect from the server. If you want to send another mail, you should repeat the 'rcpt to:' and 'data' commands. There is no need for 'helo' and 'mail from:', because the server already knows who you are. If you want to disconnect, just say 'quit':

`quit`

The server will reply:

`221 Bye`

and you will lose connection with the server.