Use the mail command in Ubuntu to send emails

Source: Internet
Author: User


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.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.