Operation and Maintenance department in the monitoring system, all need to have the mail alarm function, but like the past cacti there is no such function.
The Mail command from Linux allows you to send messages either internally or externally.
How Mail is sent:
1 echo "Mail Content" | Mail-s "Mail Header" receiver address
2 Saving the contents of a message as a file
Mail-s "Mail title" email Address < mail content file
Send mail to System local account:
echo "Root_status" | Mail-s "root" [email protected]
Tail/var/spool/mail/root
Subject:root
User-agent:heirloom MAILX 12.4 7/29/08
mime-version:1.0
Content-type:text/plain; Charset=us-ascii
Content-transfer-encoding:7bit
Message-id: <[email protected]_web01.localdomain>
From: [Email protected] (root)
Root_status
Send via external SMTP (take 163 for example)
1 apply for external email [email protected]
2 Confirm 163 of SMTP information
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/84/3D/wKiom1eJpjTAU-dbAACNCPgHWsU769.jpg "title=" 163- Smtp. JPG "alt=" Wkiom1ejpjtau-dbaacncpghwsu769.jpg "/>
2 Configure/etc/mail.rc, add the following content
#send the mail from WHO
Set [email protected] (mail sender)
# Setsmtp=smtp://smtp.server.tld:port_number
Set smtp=smtp.163.com (SMTP server information)
# tell MAILX the IT needs to authorise
Set Smtp-auth=login (identity authentication mode)
# Set the user for SMTP
# set [email protected]
Set [email protected] (Application email account)
# Set the password for authorisation
Set smtp-auth-password=mailchina654 (Application email password)
3 Testing
The message header and content to be cautious, otherwise it is easy to be considered spam, the following error occurred:
echo "Hello Clark" | Mail-s "Hello" [email protected]
[[Email protected]]# smtp-server:554 dt:spm 163 smtp4,dtgowaannbinqilxp0ohaa--. 4861s2 1468639399,please See/http mail.163.com/help/help_spam_16.htm?ip=112.81.40.212&hostid=smtp4&time=1468639399
"/root/dead.letter" 0/0
... message not sent.
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/84/3E/wKioL1eJq1ng_H1xAABTWh-f27c187.jpg "title=" 163- SMTP2. JPG "alt=" Wkiol1ejq1ng_h1xaabtwh-f27c187.jpg "/>
Modify the message title and content and test again:
echo "Network--clark" | Mail-s "Network Status" [email protected]
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/84/3E/wKiom1eJq5TyzegoAABMwS61NUo961.jpg "title=" 163- SMTP3. JPG "alt=" Wkiom1ejq5tyzegoaabmws61nuo961.jpg "/>
Can receive, test successfully.
163 Enterprise return error message View URL:
Http://help.163.com/09/1224/17/5RAJ4LMH00753VB8.html
This article is from "Clark's operation and Maintenance" blog, reproduced please contact the author!
Linux Mail notifications