邮箱邮件

# yum -y install mailx
vim /etc/mail.rc
# 新增
set from= #邮箱
set smtp=smtps://smtp.mxhichina.com:465   # 阿里企业邮箱smtp
set smtp-auth-user=.cn # 邮箱
set smtp-auth-password=pass  # 密码
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/root/.certs


# yum -y install nss-tools 

# echo -n | openssl s_client -connect smtp.mxhichina.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /root/.certs/ding.crt

# /usr/bin/certutil -A -n "GeoTrust SSL CA" -t "C,," -d /root/.certs -i /root/.certs/ding.crt

# certutil -A -n "GeoTrust Global CA" -t "C,," -d /root/.certs -i /root/.certs/ding.crt

# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d /root/.certs/./ -i /root/.certs/ding.crt

[root@iZbp1hl4uepumhapmjs26nZ certificates]# cat mail.sh 
#!/bin/bash
read -p "Please input user name: " name
read -p "Please input the password of users: " pass
id $name &> /dev/null
if [ $? -ne 0 ]
then
    useradd $name -s /sbin/nologin
    echo "$pass" | passwd --stdin $name
else
    echo "The user already exists" && exit
fi
echo "$name 用户创建成功" | mail -s "linux用户创建"   XXX@qq.com >>/dev/null
原文地址:https://www.cnblogs.com/Applogize/p/15271944.html