The easiest way to send a Linux email
Recently want to monitor the system through the Linux situation and automatic alarm, the general Linux to send the alarm mail through the local mailbox or external mailbox server, here with the simplest way to achieve Linux using the external mailbox can send mail function, you simply register a domestic mail service provider, such as 163, You can also use the company mailbox, you need to install the MAILX tool, MAILX is a small mail-sending program.
The specific steps are as follows:
1, installation
[root@001 ~]# Yum Install Mailx
2, edit the configuration file
[root@001 ~]# vim/etc/mail.rc #添加如下内容
Set from=xxxx@126.com
Set smtp=smtp.126.com
Set smtp-auth-user=xx@126.com
Set Smtp-auth-password=xxx
Set Smtp-auth=login
---description
From: The sender that appears when the other person receives the message
SMTP: Specify SMTP server addresses for third party outgoing messages
Set Smtp-auth-user: User name for third party outgoing mail
Set Smtp-auth-password: User name corresponding to the password, some mailboxes are filled with authorization code
Smtp-auth:smtp authentication method, the default is login, can also be changed to CRAM-MD5 or plain mode
3, testing
[root@001 ~]# mail-s "HESAUCAQ" 83xx@qq.com </etc/passwd
[root@001 ~]# echo "Test Message" | Mail-s "Test" 83xx@qq.com
The above has implemented the email function ...
In the case of: 554 DT:SPM sent the content of the message contains not NetEase license information, or violate NetEase's anti-spam terms, you can send their own mailbox.
1) No message body
Mail-s "Subject" Inbox address
% mail-s "Test" 1968089885@foxmail.com
2 There is the message body mail-s "subject" Inbox address < file (message text. txt)
% mail-s "Mail Subject" 1968089885@foxmail.com </data/findyou.txt echo "message body" | Mail-s Mail Subject Address
% echo "message body content" | Mail-s "Mail Subject" 1968089885@foxmail.com cat message body. txt | Mail-s Mail Subject Address
% Cat/data/findyou.txt | Mail-s "Mail Subject" 1968089885@foxmail.com
3) with Attachment Mail-s "subject" address-a Attachment < file (message text. txt)
% mail-s "Mail Subject" 1968089885@foxmail.com-a/data/findyou.tar.gz </data/findyou.txt reprinted from: https://www.cnblogs.com/ Imweihao/p/7250500.html