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.