會話 片語 短句 94215 句型 諺語 單字


[學習] [Linux] 使用Ubuntu如何從命令列透過mutt及gmail寄信

  • 安裝mutt:
    sudo apt-get install mutt

  • 設定mutt:
    sudo gedit ~/.muttrc
    set from = "USER@gmail.com"
    set realname = "NAME"
    set imap_user = "USER@gmail.com"
    set imap_pass = "PASSWORD"
    set folder = "imaps://imap.gmail.com:993"
    set spoolfile = "+INBOX"
    set postponed ="+[Gmail]/Drafts"
    set header_cache =~/.mutt/cache/headers
    set message_cachedir =~/.mutt/cache/bodies
    set certificate_file =~/.mutt/certificates
    set smtp_url = "smtp://USER@smtp.gmail.com:587/"
    set smtp_pass = "PASSWORD"
    set move = no
    set imap_keepalive = 900

  • 產生資料夾:
    sudo mkdir -p /.mutt/cache
     
  • 送出信件範例: 
    範例1:  mutt -s "Test from mutt" user@yahoo.com < /tmp/message.txt
    範例2:  mutt -s "Test from mutt" user@yahoo.com < /tmp/message.txt -a /tmp/file.jpg
    範例3:  echo "This is the body" | mutt -s "Testing mutt" user@yahoo.com -a /tmp/XDefd.png

    -s "Test from mutt" 是信件標題
    -a /tmp/file.jpg 是要寄的附件
    /tmp/message.txt 是信件內文的內容