How to send mail from linux terminal

There are several ways to send mail from a Linux terminal. Here are a few methods:

Method 1: Using the mail command

The mail command is a simple way to send an email from the terminal. You can use it to send a plain text email to a recipient.

Syntax: mail -s "Subject" [email protected]

Example: mail -s "Hello World" [email protected]

This will open a text editor where you can type your email message. When you're done, save the file and exit the editor. The email will be sent to the recipient.

Method 2: Using the sendmail command

The sendmail command is a more powerful way to send email from the terminal. You can use it to send emails with attachments and more complex formatting.

Syntax: sendmail -t -i [email protected]

Example: `sendmail -t -i [email protected] << EOF Subject: Hello World

This is a test email. EOF`

This will send an email with the subject "Hello World" and the body "This is a test email." to the recipient.

Method 3: Using the mutt command

The mutt command is a popular email client that can be used to send and receive email from the terminal.

Syntax: mutt -s "Subject" [email protected]

Example: mutt -s "Hello World" [email protected]

This will open a text-based email client where you can compose and send an email.

Method 4: Using the msmtp command

The msmtp command is a simple email client that can be used to send email from the terminal.

Syntax: `msmtp -a [email protected] << EOF Subject: Hello World

This is a test email. EOF`

Example: `msmtp -a [email protected] << EOF Subject: Hello World

This is a test email. EOF`

This will send an email with the subject "Hello World" and the body "This is a test email." to the recipient.

Method 5: Using the mailx command

The mailx command is a simple way to send email from the terminal. It's similar to the mail command, but it allows you to specify the recipient and subject separately.

Syntax: mailx -s "Subject" [email protected]

Example: mailx -s "Hello World" [email protected]

This will open a text editor where you can type your email message. When you're done, save the file and exit the editor. The email will be sent to the recipient.

These are just a few examples of how you can send mail from a Linux terminal. The specific method you use will depend on your personal preference and the features you need.