邮箱邮件
# 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
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步