有很多程式於 bash shell 執行, 執行完要自動寄信出去, 但是最近都被 Google 退信, 最好的方法是透過 Gmail 直接寄信.

本來是要另外寫隻 script 來做這種事, 剛剛發現 $4 的介紹文, 真是超方便的, 一樣使用原本 shell 的 mail, script 都不需要改, 只要設定設一設即可~

 原文:http://blog.longwin.com.tw/2009/08/ssmtp-shell-gmail-send-mail-2009/

ssmtp 安裝、設定

  1. apt-get install ssmtp # 註: 若有安裝 Postfix, Postfix 會被移除.
  2. vim /etc/ssmtp/ssmtp.conf

    AuthUser=user.name@gmail.com # 寄件者帳號
    AuthPass=password # 寄件者密碼
    FromLineOverride=YES
    mailhub=smtp.gmail.com:587
    UseSTARTTLS=YES

測試

    • 下述的 mail 可選用 mailutils 或 mailx 的 mail 程式.
    • echo "This is a test mail." | mail -s "test mail" rec.user.name@gmail.com

相关文章:

  • 2021-09-02
  • 2021-05-30
  • 2022-03-07
  • 2022-01-22
  • 2021-12-23
  • 2022-01-08
  • 2021-08-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
  • 2021-05-20
  • 2021-10-19
相关资源
相似解决方案