歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 在RHEL6中使用mail命令發外部郵件

在RHEL6中使用mail命令發外部郵件

日期:2017/2/28 14:45:25   编辑:Linux教程

在RHEL6中使用mail命令發外部郵件

首先,卸載掉系統自帶的sendmail和postfix:

yum remove sendmail

yum remove postfix

然後在/etc/mail.rc中添加下面幾行:

set [email protected]

set smtp=smtp.126.com

set smtp-auth-user=123456

set smtp-auth-password=xxxxxxx

set smtp-auth=login

說明:from是指發件人,smtp-auth-user和smtp-auth-password是指用戶名和密碼,smtp-auth配置為登錄方式。

接下來就是使用mail命令來發郵件了,執行下面的命令:

echo "Content Hello" | mail -s "Test Title" -a testfile.txt [email protected]

說明:echo的內容為郵件正文,-s是指郵件標題,-a是指附件,最後的[email protected]是指收件人。

更多用法請參考mail的man手冊。

Copyright © Linux教程網 All Rights Reserved