Send mail smtp command line

Here are the basic SMTP commands to send an email using the command line:

Step 1: Connect to the SMTP server

telnet <smtp_server> <smtp_port>

Replace <smtp_server> with the hostname or IP address of your SMTP server, and <smtp_port> with the port number (usually 25 or 587).

For example:

telnet smtp.gmail.com 587

Step 2: Authenticate

AUTH <auth_type> <username> <password>

Replace <auth_type> with the authentication type (e.g. PLAIN, LOGIN, or CRAM-MD5), <username> with your email address, and <password> with your email password.

For example:

AUTH LOGIN
<username>
<password>

Step 3: Send the email

MAIL FROM: <from_email>

Replace <from_email> with the email address you want to send the email from.

RCPT TO: <to_email>

Replace <to_email> with the email address you want to send the email to.

DATA

This command starts the email body.

Subject: <subject>

Replace <subject> with the subject of the email.

From: <from_email>

Replace <from_email> with the email address you want to send the email from.

To: <to_email>

Replace <to_email> with the email address you want to send the email to.

Body: <email_body>

Replace <email_body> with the body of the email.

.

This command ends the email body.

Step 4: Quit

QUIT

This command disconnects from the SMTP server.

Here's an example of the entire command sequence:

telnet smtp.gmail.com 587
AUTH LOGIN
<username>
<password>
MAIL FROM: [email protected]
RCPT TO: [email protected]
DATA
Subject: Test email
From: [email protected]
To: [email protected]
Body: This is a test email.
.
QUIT

Note: You may need to use additional commands or options depending on your specific SMTP server and email client configuration. Additionally, be aware that sending emails using the command line may not be secure or reliable, and you may want to consider using a dedicated email client or API instead.