Linux sends mail to external mailboxes via SendMail

Source: Internet
Author: User
Tags bz2


Linux sends mail to external mailboxes via SendMail

Recently in writing automated patrol scripts, thinking how to alert after automatic email alerts.

First download the latest version mailx-12.4.tar.bz2

# wget http://sourceforge.net/projects/heirloom/files/latest/download?source=files

Unpack the package:

# tar jxvf mailx-12.4. tar.bz2# cd mailx-12.4# make# make install Ucbinstall=/usr/ Bin/install

Note: If you do not uninstall the old version of MAILX, you cannot use the MAILX or mail command directly, otherwise the legacy MAILX is still used.

View version number:

/home/mailx-12.4/MAILX-  V

Write. BASHRC

# vi/root/. BASHRC Add a line: Alias mail='/home/mailx-12.4/mailx'/root/. Bashrc

Then execute the Mail command to represent the new MAILX.

Next configure the new MAILX to send mail using an external mailbox:

Edit/etc/nail.rc (note not the old version of/etc/mail.rc):

Vi/etc/nail.rc Add two lines:

Setfrom [email protected] smtp=smtp.linuxidc.comset smtp-auth-user=myname Smtp-auth-password=password Smtp-auth=login

The first line indicates the external mailbox and SMTP server used

The second line indicates the user name and password used by the external mailbox

Save and restart the SendMail service

Service SendMail Restart

If you perform an error:

Sendmail:unrecognized Service

Because the SendMail is not installed, it is OK to install it via Yum

Yum Install SendMail

Installation successful, continue to restart SendMail service step

SendMail How to use it after successful startup?

#echo'Tset'| Mail-s"test test"[Email protected]163. Com#echo'Tset'Show Content #-S"test test"indicates the title # can also print the entire file contents #cat/home/tset.log | Mail-s"test test"[Email protected]163. com
 
   Yum install-y sendmail Mailx
Vim/etc/mail.rc



From for notes (Wiz)

Linux sends mail to external mailboxes via SendMail

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.