Telnet mail command

A blast from the past!

The telnet command is a classic Unix utility that allows you to establish a connection to a remote server or service over a network. In the case of the mail command, you can use telnet to connect to a mail server and interact with it using a simple text-based interface.

Here's an example of how to use telnet to connect to a mail server and send an email:

telnet mail.example.com 25

Replace mail.example.com with the hostname or IP address of your mail server, and 25 with the port number (in this case, the default SMTP port).

Once you've connected, you'll see a prompt like this:

220 mail.example.com ESMTP Sendmail 8.15.2/8.15.2; Wed, 12 Jan 2022 14:30:00 -0500

This is the mail server's greeting message. You can now enter commands to interact with the mail server. Here are some common commands:

Here's an example of how you might use these commands:

HELO example.com
250 mail.example.com Hello example.com [192.0.2.1], pleased to meet you
MAIL FROM: <[email protected]>
250 2.1.0 [email protected]... Sender ok
RCPT TO: <[email protected]>
250 2.1.5 [email protected]... Recipient ok
DATA
Subject: Test email from telnet

This is a test email sent using telnet.
.
250 2.6.0 Message accepted for delivery
QUIT
221 2.0.0 mail.example.com closing connection

When you're finished, type QUIT to disconnect from the mail server.

Keep in mind that this is a very basic example, and you may need to use additional commands or options depending on the specific requirements of your mail server or email client.