pikesaku’s blog

個人的な勉強メモです。記載内容について一切の責任は持ちません。

muttでメール送信

使い方

echo "MESSAGE" | mutt [OPTION] 宛先アドレス
mailコマンドと似た感じで使える

参考

man mutt(1)
man muttrc(5)


件名設定

$ echo test | mutt -s 'test' root@example.com


MTA指定

$ echo test | mutt -e 'set smtp_url="smtp://127.0.0.1:25"' root@example.com


送信元(Envelope from)指定

$ echo test | mutt -e 'set smtp_url="smtp://127.0.0.1:25"' -e 'set use_envelope_from=yes' -e 'set envelope_from_address="hoge@example.com"' root@example.com


添付ファイル送信

$ echo test | mutt -a /etc/hosts /bin/cp -- root@example.com

複数ファイル指定可能、MIMEエンコーディングされる。
テキストデータはcontent-typeがtext/plain、バイナリファイルはapplication/octet-stream
添付ファイルと宛先アドレスの間に、--を入れる必要あり


任意ヘッダ設定

$ echo test | mutt -e 'my_hdr x-hoge1: hoge1' -e 'my_hdr x-hoge2: hoge2'  root@example.com


指定ファイルのデータを本文に利用

$ mutt -s   "test" both@example.com < /etc/hosts