Telnet smtp send email example

Here is an example of how to use telnet to send an email using the SMTP protocol:

Step 1: Connect to the SMTP server

Open a terminal or command prompt and type:

telnet smtp.example.com 25

Replace smtp.example.com with the hostname or IP address of your SMTP server. The port number 25 is the default port for SMTP.

Step 2: Send the SMTP command

Once connected, you will see a prompt that looks like this:

Trying 192.0.2.1...
Connected to smtp.example.com.
Escape character is '^]'.
220 smtp.example.com ESMTP

To send an email, you need to issue the HELO command to identify yourself and the MAIL FROM command to specify the sender's email address. Type:

HELO client

This will send the HELO command to the SMTP server.

Step 3: Specify the sender's email address

Type:

MAIL FROM: <[email protected]>

Replace [email protected] with the email address of the person sending the email.

Step 4: Specify the recipient's email address

Type:

RCPT TO: <[email protected]>

Replace [email protected] with the email address of the person receiving the email.

Step 5: Specify the email subject and body

Type:

DATA

This will start the email body. Type the subject and body of the email, followed by a period (.) to indicate the end of the email body.

For example:

Subject: Test email from telnet

This is a test email sent using telnet.
.

Step 6: Send the email

Type:

QUIT

This will send the email and close the connection.

Example output

Here is an example of what the output might look like:

Trying 192.0.2.1...
Connected to smtp.example.com.
Escape character is '^]'.
220 smtp.example.com ESMTP
HELO client
250 smtp.example.com
MAIL FROM: <[email protected]>
250 2.1.0 Sender <[email protected]> okay
RCPT TO: <[email protected]>
250 2.1.5 Recipient <[email protected]> okay
DATA
354 Start mail input; end with <CRLF>.<CRLF>
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 Bye
Connection closed by foreign host.

Note that this is just a basic example, and you may need to add additional headers or authentication information depending on the specific requirements of your SMTP server.