The System Manager often encounters the warning and the notification to the equipment or the task, usually sends the text message, the mail and so on way. Send text messages generally need to have SMS cat (hardware) or call libfetion to send to fetion users. This article describes several simple ways to send a message.
This article environment: Ubuntu 10.04
Basis:
Linux server send mail is generally based on SendMail, SendMail server provides external mail sending function. Other tools are serviced based on the SendMail. So to send Mail on a Linux system, you first need to install the SendMail Server installation method:
- #sudo Apt-get Install SendMail
Then through PS to see if there is a sendmail process, if present, the installation succeeds:
- #ps-ef|grep SendMail
- Root 1282 1 0 13:39? 00:00:00 sendmail:MTA:accepting Connections
Once you've successfully installed SendMail, you're ready to send mail to your mail account.
===================== Split line ===============================
This article lists the common ways to send mail under Linux for your reference.
Method 1 :
Directly use SendMail, edit the following file a.sh, through chmod to change permissions after execution.
- #!/bin/bash
- /usr/sbin/sendmail-t << EOF
- from:mail test <[email& Nbsp;protected]>
- to: [email protected]
- CC: [email protected]
- subject:mail testing
- ----------------------------------
- this is the mail content ...
- muhaha
- ---------------------------------
- eof
Mans SendMail
The meaning of the-t parameter
-T Read message for recipients. To:, Cc:, and Bcc:lines 'll be
Scanned for recipient addresses. The Bcc:line'll be deleted
Before transmission.
In addition, SendMail reads the content from the standard input to the end or encounters "." By default, and-oi is thinking of encountering "." No longer think of it as a terminator. As follows:
echo "hahaha.my" |sendmail-oi [email protected]
Method 2:
Send mail using mail tool, must install Mailutils
- sudo apt-get install mailutils
Then send the message
- $ mail-s "Just a test" recipient e-mail address < message content file to be sent
- Mail-s "haha" [email protected] < Hello.txt
The-T of the Mail tool can be followed by multiple users, as follows:
- Mail-s title-t [email protected]-t [email protected] < Hello.txt
If you want to send a message with an attachment, you need to install Uuencode,uuencode in the Sharutils package first
- sudo apt-get install sharutils
and then send
Uuencode Attachment name Display attachment name | Mail-s Topic Purpose Mailbox
- Uuencode hello.txt bienvenu |mail-s Test [email protected]
If you follow the above method, the message will be sent with only one attachment, and the text and attachments form a federated file.
Method 3:
Using Formail and SendMail to send together:
Formail can encapsulate the message information and then call SendMail to send, the classic example is as follows:
- echo hello|formail-i "From:[email protected" "-I" mime-version:1.0 "-i" content-type:text/html;charset=gb2312 "-i" Subject:test "|sendmail-oi [email protected]
Method 4:
Send using Mutt
Mutt is a very useful email program under Linux, the most typical example of which is as follows:
Mutt-s "Test Mail" [email protected]-Test.jpg < Hello.txt
of which: s-Theme A-attachment
The last addition is the message content Mutt can even use PGP encryption, the use of Mutt support mime, to solve garbled problems, in short mutt is the best use of personal email tools.
This issue of knowledge is introduced here, I hope you can have something to gain. Share a word: To have a dream, even if it seems far away.
Send mail under Linux server