CentOS7配置sendmail發送QQ郵件

1.安裝sendmail

yum install sendmail -y

systemctl status sendmail # 查看sendmail運行狀態
systemctl start sendmail # 啓動
systemctl enable sendmail # 設置開機自啓
systemctl is-enabled sendmail # 查看是否設置開機自啓

2.安裝mailx

yum install mailx -y

3.發送郵件

3.1 通過文件發送

vim test.txt
hello world!!

mail -s 'mail test' [email protected] < test.txt

在這裏插入圖片描述

3.2 通過管道符發送

echo "this is my test mail" | mail -s 'mail test2' [email protected]

在這裏插入圖片描述

4.設置發件人信息

如果不設置發件人信息,上述發送郵件默認會使用linux當前登錄用戶名(root),通常會被當成垃圾郵件被攔截,取回之後纔可以查看。
在這裏插入圖片描述

在這裏插入圖片描述
指定發件人郵箱信息命令:vim /etc/mail.rc,編輯內容如下:

vim /etc/mail.rc
set [email protected]
set smtp=smtp.qq.com
set [email protected]
set smtp-auth-password=nibojgkhlmhkbafbv

注意配置中的smtp-auth-password不是郵箱登錄密碼,是郵箱服務器開啓smtp的授權碼,每個郵箱開啓授權碼操作不同

在這裏插入圖片描述
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章