The mail command is a simple command-line utility used to send and receive emails. To send an email using the mail command, you can follow these steps:
Basic Syntax
The basic syntax for sending an email is as follows:
mail -s "Subject" recipient@example.com
Steps to Send an Email
-
Open the Terminal: Launch your terminal application.
-
Use the
mailCommand:- To send an email, type the command with the subject and recipient's email address:
mail -s "Your Subject Here" recipient@example.com
- To send an email, type the command with the subject and recipient's email address:
-
Compose the Email:
- After entering the command, press
Enter. You will be prompted to enter the body of the email. Type your message.
- After entering the command, press
-
End the Email:
- To finish composing the email, press
Ctrl + D(EOF - End of File) on a new line. This will send the email.
- To finish composing the email, press
Example
Here’s an example of sending an email:
mail -s "Meeting Reminder" john.doe@example.com
After pressing Enter, type your message, and then press Ctrl + D to send it.
Additional Options
-
CC/BCC: You can add CC or BCC recipients by using the
-cor-boptions, respectively:mail -s "Subject" -c cc@example.com -b bcc@example.com recipient@example.com -
Attachments: To send an email with an attachment, you can use the
-aoption:mail -s "Subject" -a /path/to/file recipient@example.com
Note
Make sure that your system is configured to send emails (e.g., with a mail transfer agent like Postfix or Sendmail) for the mail command to work properly.
