天天看點

linux下sendmail

1. 安裝

bin/mail會預設使用本地sendmail發送郵件,這樣要求本地的機器必須安裝和啟動sendmail服務,配置非常麻煩,而且會帶來不必要的資源占用

通過修改配置檔案,可以使用外部的smtp伺服器發送郵件

2. 配置

# vi /etc/mail.rc
set [email protected].com  
set smtp=smtp.qq.com 
set [email protected].com  
set smtp-auth-password=password (賬戶密碼)
set smtp-auth=login
           

from是發送的郵件位址

smtp是外部smtp伺服器的位址

smtp-auth-user是外部smtp伺服器認證的使用者名

smtp-auth-password是外部smtp伺服器認證的使用者密碼

smtp-auth是郵件認證的方式

3. 測試

# echo "hello word" | mail -s "test" [email protected]
# mail -s "test" [email protected] <content.txt
           

-s是郵件主題

@是收件人

content是郵件正文

4. 設定ssl郵箱

複制證書檔案

在裝有Firefox的Linux電腦,找到 ~/.mozilla/firefox/xxxxxxxx.default/ 的 cert*.db 與 key*.db

5. 配置

set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb   //證書路徑
set from=[email protected].com
set smtp=smtps://smtp.qq.com:465    //ssl端口
set smtp-auth-user=[email protected].com
set smtp-auth-password=password 
set smtp-auth=login
           

再次測試

繼續閱讀