[toc]
Linux用QQ郵箱發送郵件
運維工程師工作中經常會需要用郵箱去接收服務器告警信息,可以使用下面方式配置QQ郵箱發送郵件接收告警。
登錄QQ郵箱---賬號與安全---安全設置---生成授權碼
服務器配置
centos
# 安裝客户端
yum install mailx -y
# 配置郵箱信息
[root@centos7 ~]# vim /etc/mail.rc
set from=122841644@qq.com # 填寫自己的郵箱地址
set smtp=smtp://smtp.qq.com:587
set smtp-auth-user=122841644@qq.com # 填寫自己的郵箱地址
set smtp-auth-password="填寫自己生成的授權碼"
set smtp-auth=login
set ssl-verify=ignore
set smtp-use-starttls
set nss-config-dir=/etc/pki/nssdb
# 發送郵件測試
echo 'linux mail test' | mail -s 'mail test' waluna@qq.com
# 24年後QQ加強安全驗證,有報錯忽略就好。
Ubuntu
# 安裝客户端
apt install s-nail -y
# 配置郵箱信息
[root@ubuntu2204 ~]# vim /etc/s-nail.rc
set from=122841644@qq.com # 填寫自己的郵箱地址
set smtp=smtp://smtp.qq.com:587
set smtp-auth-user=122841644@qq.com # 填寫自己的郵箱地址
set smtp-auth-password="填寫自己生成的授權碼"
set smtp-auth=login
set ssl-verify=ignore
set smtp-use-starttls
set nss-config-dir=/etc/pki/nssdb
# 發送郵件測試
echo 'linux mail test' | s-nail -s 'mail test' waluna@qq.com
# 24年後QQ加強安全驗證,有報錯忽略就好。
去郵箱查看郵件
關於我
全網可搜《阿賢Linux》
CSDN、知乎、嗶哩嗶哩、博客園、51CTO、掘金、思否、阿里雲、騰訊雲、華為雲、今日頭條、百家號、GitHub、個人博客
公眾號:阿賢Linux
個人博客:blog.waluna.top
https://blog.waluna.top/
原文鏈接: Linux用QQ郵箱發送郵件.