#!/bin/bash
#Description:     The test script
#QQ:             2041598918
#Author:          mengyuanxi
#email:          2041598918@qq.com 
#FileName:        mail.sh
#Date:            2021-12-25
#=======================================================
yum -y install postfix mailx systemctl &>/dev/null && echo -e "\e[32m 下载成功!\e[0m" || echo "\e[31m 下载失败!\e[0m"

systemctl enable --now postfix &>/dev/null && echo -e "\e[32m 启动完成!\e[0m" || echo "\e[31m 启动失败!\e[0m"

read -p "请输入邮箱地址:" from
read -p "请输入用户名:" name
read -p "请输入 smtp.qq.com 或 smtp.163.com :" smtp
read -p "请输入授权码:" passwd

cat >>/etc/mail.rc<<EOF
set from=$from
set name="$name"
set smtp=$smtp
set smtp-auth-user=$from
set smtp-auth-password=$passwd
set smtp-auth=login
set ssl-verify=ignore
EOF

echo 

tail -7 /etc/mail.rc

# 发送测试邮件
echo 邮件服务搭建成功! | mail -s "test" $from

echo "该脚本执行后产生的一切后果本人概不负责!!!"

磁盘告急

#!/bin/bash

DISK_USED=`df -h | grep "/$" | tr -s ' ' | cut -d' ' -f5 | grep -o [0-9]*`

[ "$DISK_USED" -ge 30 ] && echo "你的磁盘占用已经达到"$DISK_USED%",请及时清理
!" | mail -s '磁盘告急' 2041598918@qq.com