1、安裝sendmail: 1) centos下能夠安裝命令:yum -y install sendmail 2) 安裝完後啓動sendmail命令:service sendmail start 2、安裝mail 安裝命令:yum install -y mailx
一、經過文件內容發送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
上述發送郵件默認會使用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