When you use the mail command in Ubuntu to send an email to back up data, You need to log on to the server every day to check whether the backup is successful. So I learned how to use shell to send emails to my mailbox in linux. Here we use ubuntu as an example to use the mail command to send external emails. The syntax of the mail command is as follows: Usage: mail [-iInv www.2cto.com] [-s subject] [-c cc-addr] [-B bcc-addr] to-addr... [-- sendmail-options...] mail [-iInNv]-f [name] mail [-iInNv www.2cto.com] [-u user] use the mail command to send emails. There are three methods: 1. directly use shell as the editor mail www.2cto.com-s "test" davis @ gmail. com hello, davis welcome to you! The first line is the input command,-s indicates the subject of the mail, followed by the davis@gmail.com is the recipient of the mail, enter this line of command and press enter, will enter the body of the mail writing, we can enter any text, such as the above two lines. After entering the body of the email, press CTRL + D to complete the input. At this time, you will be prompted to enter the Cc address, that is, the Cc address. If you do not press enter, the email will be sent. Www.2cto.com 2. Send echo "hello, davis. \ n This is a test mail "www.2cto.com | mail-s" test "davis @ gmail. com can use the pipeline to directly input this line of command to complete the mail sending, where the echo is the mail body. 3. Use the file to send mail www.2cto.com-s "Hello davis" davis @ gmail. com <mail.txt use the following command, we can send the contents of the mail.txt file to the davis@gmail.com as the mail content. Some other parameters are not described.