PS
本例使用Tencent轻量级服务器
阿里云服务器会禁用端口,请参考其它文章(阿里的:smtp使用协议smtp=smtps://smtp.163.com:465,还要配置相关证书。。。)
SMTP
去163邮箱设置里打开smtp,并增加授权码(只显示一次,请牢记)
安装mailx
只需要安装mailx即可
yum install mailx -y
/etc/mail.rc配置
# mail config
set from=username@163.com #发送者邮箱
set smtp=smtp.163.com #无证书写法
set smtp-auth-user=username@163.com #邮箱
set smtp-auth-password="xxxxxxxxxx" #授权码
set smtp-auth=login
测试
echo "hello" | mail -s test username@163.com
mail 的具体使用方法请参见mail命令、文档