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