Mail command linux
The mail
command in Linux is a utility that allows you to send and receive email messages. Here are some basic commands and options:
Sending Email
mail -s "Subject" [email protected]
: Send an email with a subject line to the specified recipient.mail -c "Content" [email protected]
: Send an email with a custom content to the specified recipient.mail -a "Attachment" [email protected]
: Send an email with an attachment to the specified recipient.
Receiving Email
mail
: Check for new email messages and display them in a list.mail -f
: Check for new email messages and display them in a list, including the full message body.mail -d
: Delete all new email messages.
Managing Email
mail -r
: Reply to a specific email message.mail -f
: Forward a specific email message to another recipient.mail -d
: Delete a specific email message.mail -s
: Save a specific email message to a file.
Options
-s
: Specify the subject line of the email message.-c
: Specify the content of the email message.-a
: Specify an attachment to be sent with the email message.-f
: Check for new email messages and display them in a list, including the full message body.-d
: Delete all new email messages.-r
: Reply to a specific email message.-f
: Forward a specific email message to another recipient.-d
: Delete a specific email message.-s
: Save a specific email message to a file.
Examples
- Send an email to
[email protected]
with the subject "Hello" and the content "Hello, how are you?":mail -s "Hello" -c "Hello, how are you?" [email protected]
- Check for new email messages and display them in a list:
mail
- Delete all new email messages:
mail -d
- Reply to an email message with the subject "Re: Hello":
mail -r "Re: Hello"
Note: The
mail
command is a simple email client and does not support many features that are available in modern email clients. It is recommended to use a more advanced email client such asmutt
ormsmtp
for more complex email tasks.