Sending eMail Using Telnet (SMTP Commands)
If you ever find yourself in a situation where you have to test a mail server via telnet, here is how you do it.
In order to access your mailbox you will need 2 things:
- The address of a mail server capable of relaying for you - usually provided by your ISP
- A valid email address
The first thing to do is to open a connection from your computer to your mail server.
- Open a telnet connection to server.
- Input HELO command
- Specify MAIL FROM (The mail server has no choice but to take your word for it as of RFC822-RFC1123. On many mailservers the space after the : is required rather that optional.)
- Specify recipient RCPT TO
- Input message DATA (Finish with the single '.' in a new line
- Issue QUIT command
Several errors and explanations
501 nouser@nosuchplace.here… Sender domain must exist - The domain that you are sending from must exist 503 Need MAIL before RCPT - A recipient has been specified before a sender. 550 mail@domain.ext… Relaying Denied - The mail server has refused to relay mail for you, this may be for any number of reasons but typical resons include:
- Not using this provider for an internet connection and/or
- Not using an email address provided by the owner of the server.
Some things to watch out for:
- If you type too quickly, sometimes it won't recognise your text
- The backspace key sometimes does not work with some telnet clients (even though it may seem as though it does)
Here is c/p from telnet (commands and output)
220 mail.example.com ESMTP Service (Lotus Domino Release 8.5.3FP5) ready at Thu, 27 Nov 2014 15:48:55 +0100 HELO domain.com 250 mail.example.com Hello domain.com ([10.238.90.163]), pleased to meet you MAIL FROM: user@domain.com 250 user@domain.com... Sender OK RCPT TO: anotheruser@anotherdomain.com 250 anotheruser@anotherdomain.com... Recipient OK DATA 354 Enter message, end with "." on a line by itself Subject:Test Body another line . 250 Message accepted for delivery quit 221 mail.example.com SMTP Service closing transmission channel Connection to host lost.