Send mail using the Linux Mail command

Source: Internet
Author: User
Tags how to send mail

Because I often work under Linux, so many times need to send their work reports or other useful things to the relevant people, so take the time to study how to send mail under Linux. We can usually use the following 3 to send the method:

1. Use the shell to send messages to the editor

This way you can edit the message body directly in the shell window and use Ctrl+d to exit when the edit is complete, and the message will be sent out.

#-S is followed by the subject of the message, followed by the destination email address
[Email protected] ~]# mail-s "Lucky Mail" [Email protected]hi tomas,thank you help! Regards,daniel

2. Using pipelines to send messages

Behind ECHO is the message body

[[email protected] ~]# echo "Hi tomas,> Thank you help!> regards,> Daniel" | Mail-s "Thank you mail" [email protected]

3. Send the message body as a file

This form is suitable for long message body writing, writing the message body to the file mail.body, and then locating the target message through <

[Email protected] ~]# mail-s "Thanks Mail" [email protected] < Mail.body

4. Send a message with an attachment

To send a message with an attachment, you need to install the Uuencode package, and you can use the following command to install the Uuencode package if the Yum source is configured

[email protected] ~]# Yum install sharutils

Install Uuencode to send mail with attachments.

# uuencode followed by two parameters, the first parameter "/root/batch.file" is the attachment full path, the second parameter "batch" is the name of the attachment displayed in the message
[[email protected] ~]# Uuencode/root/batch.file Batch | Mail-s "Batch file" [email protected] < Mail.body

Some of the above commands were tested on CentOS6.

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.