Sending mail with telnet to an smtp server

Telnet is a nice utility that lets you open a network connection to any service by specifying the port to connect to. Telnet is part of the standard set of utilities of any operating system, so the commands work the same for linux and for Windows. It is started from the command line/terminal.

In this note I want to show how to connect to an smtp server with telnet and send mail from it.

First open the connection. Run this command:

telnet smtp.example.com 25

By default smtp listens on port 25. Under certain circumstances the port can be different. Try 2525, 587 or 465.

Introduce yourself:

HELO  example.com

Set the sender address:

MAIL FROM: [email protected]

The recipient address:

Then type DATA and start typing the text of the message. At the end press Enter twice. Put a dot. And Enter again.
In response you get a message saying the message is queued for delivery.

250 2.0.0 Ok: queued as 27FE2180887