Learn about the role of Linux mail commands through examples

  
                

Linux mail command is often used by system administrators. It is a very practical command. You can send memos to remind system users regularly. The following small series will give you a detailed introduction to the mail command in Linux.

to see the mail by the first parameter help all the parameters as follows:

code is as follows:

Usage: mail [-BDFintv ~] [-s subject] [ -a attachment ] [-c cc-addr] [-b bcc-addr]

[-r from-addr] [-h hops] [-A account] [-R reply-addr] to- Addr …

mail [-BDeHiInNRv~] [-T name] [-A account] -f [name]

mail [-BDeinNRv~] [-A account] [-u User]

1. Send the title plus text content

Run the command:

The code is as follows:

mail -s “this is a title” bbmonkey62 @163.com

Enter, continue to enter text, that is, the content of the message

The code is as follows:

this is content

Then press Ctrl+D drop out.

The code is as follows:

EOT

The above is the simplest example, what if we want to send to multiple mailboxes? Add another email address after the above mailbox, separated by spaces, as follows:

The code is as follows:

mail -s “this is a title” bbmonkey62@163 .com [email protected]

In the above example, the sender is the current login user name of Linux. For example, if the user I am currently logged in as admin, the email address sent is admin@163. Com, if the mailbox suffix domain name is 163.com. But sometimes we want to write the sender's name, and we don't want to use the default email address. We can do this:

The code is as follows:

mail -s “this is a title” -r “[email protected][email protected]

At this time, the sender's mailbox becomes [email protected], some spam is used in this way, hidden Your own real email address.

If we want the recipient to reply to the email, the email address of the reply is different from our email address, then we can customize the email address as follows:

The code is as follows: Br>

mail -s “this is a title” -r “[email protected]” -R “[email protected][email protected]

Then the recipient responds By default, it will be sent to [email protected] instead of the default [email protected].

2, send attachments

Sometimes we need to send attachments, it is also very easy, as follows:

Code is as follows:

mail -s “ This is a title” -r “[email protected]” -a “/home/hadoop/report/3.txt” [email protected]
Previous12Next Total 2 Pages

Copyright © Windows knowledge All Rights Reserved