天天看點

Linux基礎指令---sendmail發送郵件

sendmail

sendmail是postfix中的一個發送郵件的代理程式,它負責發送郵件到遠端伺服器,并且可以接收郵件。sendmail在發送郵件的時候,預設從标磚輸入讀取内容,以“.”為結束。
  此指令的适用範圍:RedHat、RHEL、Ubuntu、CentOS、Fedora。
           

1、文法

sendmail  [option ...]  [recipient ...] 
           

2、選項參數清單

-bd
        進入deamon模式
  -bi
        初始化别名資料庫
  -bm
        從标準輸入讀取郵件
  -bp
        列出郵件清單
  -bs
        獨立的smtp模式,從标準輸入讀取,輸出到标準輸出
  -C
        main.cf的位置
  -F
        指定發送者的全名
  -f
        指定發送者
  -i
        忽略隻有單獨點的行
  -q
        以給定的時間間隔處理隊列中的郵件
           

3、執行個體

1)給某人發送郵件

[root@localhost ~]# sendmail david                //發送郵件給david,預設的發送者是root
  123.
  .
  [root@localhost ~]# tail /var/spool/mail/david             //檢視david郵箱,收到郵件
  Delivered-To: [email protected]
  Received: by mailsrv.david.cn (Postfix, from userid 0)
      id 5B3A7143211; Fri,  5 Oct 2018 21:33:34 +0800 (CST)
  Message-Id: <[email protected]>
  Date: Fri,  5 Oct 2018 21:33:29 +0800 (CST)
  From: [email protected] (wejie)
  To: undisclosed-recipients:;

  123.            

2)指定發送者

[root@localhost ~]# sendmail -f weijie david               //weijie發送郵件給david
  hehe
  .
  You have new mail in /var/spool/mail/root
  [root@localhost ~]# tail /var/spool/mail/david             //檢視david郵箱,發送者是魏傑

  Delivered-To: [email protected]
  Received: by mailsrv.david.cn (Postfix, from userid 0)
      id 3544314308F; Fri,  5 Oct 2018 21:37:11 +0800 (CST)
  Message-Id: <[email protected]>
  Date: Fri,  5 Oct 2018 21:37:07 +0800 (CST)
  From: [email protected] (wejie)
  To: undisclosed-recipients:;

  hehe
           

3)檢視表中有哪些字段

[root@localhost ~]# mysqlshow -u root -p test wj              //顯示資料庫test中的表wj的資訊
  Enter password: 
  Database: test  Table: wj
  +-------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+
  | Field | Type    | Collation         | Null | Key | Default | Extra | Privileges                      | Comment |
  +-------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+
  | id    | int(11) |                   | NO   |     |         |       | select,insert,update,references |         |
  | name  | text    | latin1_swedish_ci | NO   |     |         |       | select,insert,update,references |         |
  +-------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+
           
做了一個Linux學習的平台,目前出來一個雛形,各位可以參考使用
  連結:https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ  密碼:n7bk            
Linux基礎指令---sendmail發送郵件