centos7 使用指定郵箱發送郵件


一、安裝sendmail與mail

  1、安裝sendmail:

     1) centos下可以安裝命令:yum -y install sendmail

     2) 安裝完后啟動sendmail命令:service sendmail start

  2、安裝mail

     安裝命令:yum install -y mailx

 

二、發送郵件

    1、通過文件內容發送

     發送命令:mail -s 'mail test' abc@qq.com < mailtest.txt ("mail test"為郵件主題,abc@qq.com為收件人郵箱,mailtest.txt保存郵件內容)

        或者:echo "郵件內容" |mail -s "主題"  abc@qq.com

 

 

  2、通過管道符直接發送

     發送命令:echo "this is my test mail" | mail -s 'mail test' abc@qq.com

 

三、設置發件人信息

  上述發送郵件默認會使用linux當前登錄用戶信,通常會被當成垃圾郵件,指定發件人郵箱信息命令:vi /etc/mail.rc,編輯內容如:

set from=username@163.com
set smtp=smtp.163.com
set smtp-auth-user=username
set smtp-auth-password=yourpassword
set smtp-auth=login

注意:163郵箱需要開啟一個授權密碼,在非163專用客戶端登陸都要使用授權密碼登陸。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM