Detailed explanation of various parameters of mail command in Linux

Time:2020-5-21

In Linux, you type mail, and you have your inbox, and you have 20 mailing lists.
The command prompt is “&”
Unread marked as unread
H| headers display the current mailing list
L| list displays the list of currently supported commands
? | help display command parameter usage of multiple view mailing list
D delete the current message, move the pointer down. D 1-100 delete messages 1 to 100
F| from displays only simple information about the current message. F num display simple information of a certain email
F|from num pointer moves to a message
Z shows the last 20 mailing lists when you first started your inbox
When reading the email content where the current pointer is, press the space bar to turn the page, and press enter to move down one line
T|type|more|p|page num read an email
N | next {fill in nothing} read the next message content where the current pointer is located
When reading, press the space bar to turn the page, and press enter to move down one line
V| visual: the current email enters the plain text editing mode
N | next {fill in nothing} num read an email
Top displays the header of the message where the current pointer is located
File folder displays the file where the system mail is located and the total number of messages
X exits the mail command platform without saving previous operations, such as deleting mail
Q exit the mail command platform, and save the previous operations, such as deleting the mail deleted with D. the read mail will be transferred to the Mbox file in the current user’s home directory. If you delete a file in Mbox, it will be completely deleted.
Enter mail – F Mbox in Linux text command platform, and you can see the mail in the Mbox in the current directory.
CD changes the location of the current folder
When you write a letter, press Ctrl + C twice to interrupt the work and do not send the letter.
When reading a letter, press Ctrl + C once to exit reading status.

1. The simplest example:

Copy code

The code is as follows:

mail -s test [email protected]

The result of this command is to send an empty letter titled test to the following email. If you have MTA and the following email will not block this kind of letter, you will receive this letter. If you don’t want to be distracted by this mess, please use your local account for the mailbox at the back.
2. The second example:
Three common formats for sending messages

Copy code

The code is as follows:

mail -s test [email protected] #First, you can use the current shell as an editor. After editing the content, ctrl-d will finish
echo “mail content”|mail -s test [email protected] #The second method, which I use most, is probably because I like pipes
mail -s test [email protected] < file ා the third method is to send a message based on the content of file

In fact, it’s easy for you to find that the mail reads the contents of the file from the standard input and sends the message. I just want you to know this. Now, the second example is over.
3. The third example, mail with attachments
If there is no uuencode command in your system, please install sharutils (Yum install sharutils) first
Uuencode requires two parameters. The first one is the file you want to send (US). Of course, this can also be done by pipeline. The second one is the file name displayed

Copy code

The code is as follows:

uuencode /home/yfang/a.gif a.gif|mail -s pictest [email protected]
tar czf – /home/yfang/ | uuencode home.tgz |mail -s pictest [email protected]