centos7 使用指定郵箱發送郵件

1、安裝sendmail與mail

  1、安裝sendmail:

     1) centos下能夠安裝命令:yum -y install sendmail

     2) 安裝完後啓動sendmail命令:service sendmail start

  2、安裝mail

     安裝命令:yum install -y mailx

 

2、發送郵件

    一、經過文件內容發送linux

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

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

 

 

  二、經過管道符直接發送centos

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

 

3、設置發件人信息

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

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專用客戶端登錄都要使用受權密碼登錄。spa

相關文章
相關標籤/搜索