This is the 18th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

Introduction to the

We may simply monitor Linux or view the results of tasks, so we will use the mail function of Linux. Here take Mailx as an example and send it to QQ mailbox

Once the mailbox function is configured, consider the whitelist of abnormal messages

The installation

yum install -y mailx
Copy the code

Other mailbox software may exist in the system, so you need to close other mailbox tools

systemctl stop postfix
systemctl stop sendmail
Copy the code

configuration

Add the send mail configuration at the end of /etc/mail.rc

Set [email protected] set SMTP =smtp.qq.com set [email protected] set smtp-auth-password= authorization code set smtp-auth=loginCopy the code

From is the email address you set for STMP service, which is also used to send emails

SMTP occurs at the address of the external SMTP server, such as QQ’s smtp.qq.com

Smtp-auth-user Indicates the user name for external SMTP server authentication (usually an email account).

Smtp-auth-password is the user password for external SMTP server authentication (QQ is the authorization code).

Smtp-auth is an email authentication mode

use

send

Echo 'content part' | 'title name' [email protected] mail - sCopy the code

The email in the back is the email address of the person you want to send it to

If an error occurs, baidu will search for the cause

If they can’t get it, see if it’s in the trash

Shell command line edit send

$mail -s "test article" [email protected] ## enter content input mode Hello ## Body content EOT ## Press 'CTRL +D' to automatically display the end characterCopy the code

Enter mail-s “test article” [email protected] on the console and enter content input mode. You can write on line. After entering all the content to play, press CTRL +D to finish

Content is read from a file and sent

Mail -s' title '[email protected] < data.txtCopy the code

other

Please use other functions

man mail
Copy the code

conclusion

As far as the letter is not as good, the above content is purely one’s opinion, due to the limited personal ability, it is inevitable that there are omissions and mistakes, if you find bugs or have better suggestions, welcome criticism and correction, don’t hesitate to appreciate

If you like my article, you can [follow]+[like]+[comment], your three even is my forward motivation, looking forward to growing with you ~

Source: author: ZOUZDC links: https://juejin.cn/post/7028963866063306760 re the nuggets copyright owned by the author. Commercial reprint please contact the author for authorization, non-commercial reprint please indicate the source.Copy the code