Send mail under Linux server

Source: Internet
Author: User
Tags mail account

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:

    1. #sudo Apt-get Install SendMail

Then through PS to see if there is a sendmail process, if present, the installation succeeds:

    1. #ps-ef|grep SendMail
    2. 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.

    1. #!/bin/bash
    2. /usr/sbin/sendmail-t << EOF
    3. from:mail test <[email& Nbsp;protected]>
    4. to: [email protected] 
    5. CC: [email protected] 
    6. subject:mail testing 
    7. ---------------------------------- 
    8. this is the mail content ...
    9. muhaha
    10. ---------------------------------
    11. 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

    1. sudo apt-get install mailutils

Then send the message

    1. $ mail-s "Just a test" recipient e-mail address < message content file to be sent
    1. Mail-s "haha" [email protected] < Hello.txt


The-T of the Mail tool can be followed by multiple users, as follows:

    1. 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

    1. sudo apt-get install sharutils

and then send
Uuencode Attachment name Display attachment name | Mail-s Topic Purpose Mailbox

    1. 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:

    1. 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

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.