Sending An Email Using Telnet

Note: This was originally posted on a site that I used work on but its no longer online.  I still find this tutorial handy when I am testing mail out so I thought I would repost it here for easy access.

When I am setting up an external mail server for a client I sometimes find it useful to test it out by sending the raw commands via telnet. The process is pretty straight forward. I am going to run through it twice in this article depending on the reason you're here:

Getting telnet in Windows Vista

If you follow the tutorial below in vista you will hit a problem almost straight away - telnet is not installed by default in Windows Vista. I have written a separate guide explaining how to install telnet in Windows Vista.

I want to learn what it means

  1. Start off by clicking the Start button and selecting Run...

  2. Type telnet and press enter. Microsoft Telnet Client will start. It looks like a standard dos box.

  3. Type the following command, replacing mail.server.co.uk with the url or ip of your mail server.

    open mail.server.co.uk 25

    25 is the standard SMTP port. Press enter at the end and you will connect to your mail server. If this doesn't work then this is the first sign you have problems.

    Some things to check are:

    • Did you spell everything correctly?
    • Are you connected to the internet?
    • If you typed a domain, have you tried the IP?
  4. Next step is to introduce yourself to the mail server. Replace yourname with any string you like, its simply used to indentify the sending in the email servers logs.

    helo yourname
  5. Tell the mail server who is sending the email. Replace you@yourname.co.uk with your own email address. Many mail servers will let you get away with a fake email address here, but if you are testing then I would recommend using a real one.

    MAIL FROM: you@yourname.co.uk
  6. Next you have to give the destination email address. Replace them@server.co.uk with your target address.

    RCPT TO: them@server.co.uk
  7. To send the body of your message you start off with a DATA command followed by enter. The response from this command will tell you how to end your message. Its almost always a full stop (.) on its own on a new line, but you should note this down.

  8. Type your message.

  9. End the message with the command you were instructed to in step 7 (probably a .).

  10. At this point your email address has been sent. If you want to send another message then you should start over. If not then its good practice to close your connection gracefully by issuing the QUIT command.

I just need reminding

If you have used telnet before and know the basics but just need reminding of the details then this quick reference guide should get you through with the minimum of hassle.

open mail.server.co.uk 25
HELO unique-identifier
MAIL FROM: you@yourcompany.co.uk
RCPT TO: them@server.co.uk

DATA
type your message here
. [or whatever identifier you are told to use after DATA]
QUIT
  

If any of these commands don't make sense then hop back up to the top of the page and read the full explanation!

No comments :