Mail command in linux
The mail
command in Linux is a utility that allows you to send and receive email messages. Here are some basic usage examples:
Sending an email
To send an email using the mail
command, you can use the following syntax:
mail -s "Subject" [email protected]
Replace Subject
with the subject of the email and [email protected]
with the email address of the recipient.
You will then be prompted to enter the body of the email. You can type in the message and press Enter to send it.
Receiving email
To receive email using the mail
command, you can use the following syntax:
mail
This will display a list of your email messages. You can then use the following commands to manage your email:
h
orhelp
: Display help informationq
orquit
: Quit the email clientd
ordelete
: Delete the current messager
orreply
: Reply to the current messagef
orforward
: Forward the current messagep
orprint
: Print the current messages
orsave
: Save the current message to a file
Other options
Here are some other options you can use with the mail
command:
-c
or--compose
: Compose a new email message-f
or--file
: Specify a file to read the email message from-s
or--subject
: Specify the subject of the email message-a
or--attach
: Attach a file to the email message-b
or--body
: Specify the body of the email message
Examples
Here are some examples of using the mail
command:
- Send an email to a recipient:
mail -s "Hello" [email protected]
- Receive email:
mail
- Delete an email message:
mail; d
- Reply to an email message:
mail; r
- Forward an email message:
mail; f
- Print an email message:
mail; p
- Save an email message to a file:
mail; s
Note: The mail
command is a simple email client and does not support all the features of a full-fledged email client like Gmail or Outlook.