Linux 使用命令發送郵件

mail命令

1.關閉本機的sendmail服務或者postfix服務

#執行下面的命令,各位大俠都對號入座吧
#sendmial
service sendmail stop
chkconfig sendmail off
#postfix
service postfix stop
chkconfig postfix off

#再狠一點就直接卸載吧..
yum remove sendmail
yum remove postfix

2、然後修改/etc/mail.rc,在文件末尾增加以下內容,指定外部的smtp服務器地址、帳號密碼等

$ vim /etc/mail.rc  
set [email protected]
set smtp=smtp.qq.com  
set smtp-auth-user=123456
set smtp-auth-password=“寫入底下生成的授權碼”
set smtp-auth=login 

這裏使用了QQ郵箱的SMTP,需要做以下配置:
設置---->下面的開啓服務那裏---->生成授權碼

3、然後通過命令來發送郵件

echo  hello word | mail -s " title" [email protected] 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章