天天看點

Linux基礎指令---mail郵件管理程式

mail

mail是一個郵件的管理程式,可以用來發送或者接收郵件。
  此指令的适用範圍:RedHat、RHEL、Ubuntu、CentOS、Fedora。
           

1、文法

mail  [選項]  addr
           

2、參數清單

-a file
        将給定的檔案發送出去
  -b
        指定郵件盲抄送位址
  -c
        指定抄送位址
  -H
        顯示所有的郵件頭并且推出
  -i
        忽略控制台的終端信号
  -r
        設定發送者位址
  -s
        指定郵件主題
  -u
        閱讀指定使用者的郵件清單
  -v
        顯示詳細資訊
  -V
        顯示版本資訊,并退出
           

3、執行個體

1)閱讀使用者david郵件

[root@localhost ~]# mail -u david           //指定使用者,首先得到郵件清單
  Heirloom Mail version 12.4 7/29/08.  Type ? for help.
  "/var/mail/david": 10 messages 3 new
      1 root                  Thu Aug 16 17:07  21/692   "test"
      2 root                  Thu Aug 16 17:08  20/631   "test"
      3 root                  Thu Aug 16 17:10  20/602   "test"
      4 root                  Fri Aug 17 08:15  20/570   "test3"
      5 root                  Fri Aug 17 09:46  25/668   "test04"
     6 root                  Tue Aug 21 09:14  20/609   "test04"
      7 root                  Tue Aug 21 09:15  20/666   "test05"
  >N  8 wejie                 Fri Oct  5 21:32  13/403   
   N  9 wejie                 Fri Oct  5 21:33  13/400   
   N 10 wejie                 Fri Oct  5 21:37  13/406   
  & 10                //此處輸入郵件編号,可以得到具體郵件内容
  Message 10:
  From [email protected]  Fri Oct  5 21:37:11 2018
  Return-Path: <[email protected]>
  X-Original-To: david
  Delivered-To: [email protected]
  Date: Fri,  5 Oct 2018 21:37:07 +0800 (CST)
  From: [email protected] (wejie)
  To: undisclosed-recipients:;
  Status: RO

  hehe           

2)發送郵件

[root@localhost ~]# mail -r david weijie                  //發送郵件給weijie,發信人david
  Subject: test
  123
  .
  EOT
  You have new mail in /var/spool/mail/root
  [root@localhost ~]# tail /var/spool/mail/weijie          //檢視weijie郵箱,收到david郵件
  To: [email protected]
  Subject: test
  User-Agent: Heirloom mailx 12.4 7/29/08
  MIME-Version: 1.0
  Content-Type: text/plain; charset=us-ascii
  Content-Transfer-Encoding: 7bit
  Message-Id: <[email protected]>

  123
           
做了一個Linux學習的平台,目前出來一個雛形,各位可以參考使用
  連結:https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ  密碼:n7bk            
Linux基礎指令---mail郵件管理程式

繼續閱讀