Swaks – SMTP 用的瑞士軍刀

Swaks 有 SMTP 用的瑞士軍刀之稱,小巧好用。

  1. 安裝:
  2. apt -y install swaks

  3. 使用範例:
  4. 
    !/bin/bash
    export toList=user01@mail01.xxx.com,user02@mail02.xxx.com
    export toList=user03@xxx.com
    export ccList=user04@xxx.com
    export body_content=mail_content.txt
    export attach_dir=/path/swaks_mail
    export attach_name_1=filename01.odt
    export bcc_file=mail_list.csv
    export bccList=$(paste -sd, ${attach_dir}/${bcc_file})
    
    swaks --to  $toList \
          --cc  $ccList \
          --bcc $bccList \
          --from tpet@xxx.idv.tw \
          --server xxx.idv.tw \
          --port 587 \
          --tls \
          --auth LOGIN \
          --auth-user tpet \
          --auth-password "##@$!@%$" \
          --header "Subject: 大會通知信" \
          --body   @${attach_dir}/${body_content} \
          --attach-type application/vnd.oasis.opendocument.text \
          --attach @{$attach_dir}/${attach_name_1} 

     

  5. 郵件附加檔案時,依據檔案性質,需要宣告不同樣式
  6. 副檔名 MIME Type (--attach-type)
    odt application/vnd.oasis.opendocument.text
    ods application/vnd.oasis.opendocument.spreadsheet
    odp application/vnd.oasis.opendocument.presentation
    pdf application/pdf
    jpg image/jpeg
    jpeg image/jpeg
    png image/png
    gif image/gif
    docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
    xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
    zip application/zip

參考資源

  1. Swaks官方網站:https://www.jetmore.org/john/code/swaks/
  2. Swaks程式:https://github.com/jetmore/swaks

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

*