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

來源:互聯網
上載者:User

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

首先,卸載掉系統內建的sendmail和postfix:

yum remove sendmail

yum remove postfix

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

set from=123456@126.com

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 123456@qq.com

說明:echo的內容為郵件內文,-s是指郵件標題,-a是指附件,最後的123456@qq.com是指收件者。

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

推薦閱讀:

Linux 下 命令列 mail 發郵件方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.