有時候單純需要 CLI 的 MUA 來發送郵件, 如果使用 sendmail 或是 postfix 那就太浪費了.可以使用 mutt 搭配 msmtp(smtp client) 來達成, smtp 伺服器用 gmail. 安裝及設定步驟如下:
- 使用 apt-get 來安裝 mutt & msmtp
- 設定 msmtp, 設定檔放在 ~/.msmtprc
- 修改 ~/.msmtprc 的權限, 不然會出現類似下方的訊息.
- 設定 mutt, 設定檔放在 ~/.muttrc
- 現在可以使用 mutt 來發郵件拉.
sudo apt-get install mutt msmtp
echo '# Smtp account gmail
account gmail
host smtp.gmail.com
from somebody@gmail.com
auth on
user somebosy@gmail.com
password gamilpassword
port 587
# Set default account
account default : gmail' > ~/.msmtprc chmod 600 ~/.msmtprc
msmtp: /home/xxx/.msmtprc: must have no more than user read/write permissions
echo 'set sendmail="/usr/bin/msmtp"
set from="somebody<somebody@gmail.com>"' > ~/.muttrc
echo 'hello' | mutt -s 'hi' somebody@gmail.comref: this, this, this & this