* 本章主要講解利用mail命令發送到外部郵件,不包括接受郵件,如果要收發郵件需要搭建郵件服務器比如安裝sendmail軟件

1、如果沒有安裝mail 使用yum -y install mailx

2、在/etc/mail.rc文件下面增加以下幾行

set from=1000000000@139.com(發送的外部郵件地址)
set smtp=smtp.139.com (發送的外部smtp服務器的地址
set smtp-auth-user=1000000000 (用戶名)

set smtp-auth-password=123456 (密碼)
set smtp-auth=login (登錄方式)

3、mail命令測試

echo "hello world" | mail -s "title" 100000000@139.com

其中title是標題,echo后面輸出的是正文

也可以 mail -s "title" 100000000@139.com,然后輸入正文,輸入.結束