2

現在、mailx を使用して、スクリプトから HTML 形式のメールを送信しています。

cat body.html | /usr/bin/mailx -a "From: Me <me@domain>" -a "Content-type: text/html" -s "My subject" $RECIPIENTS

添付ファイル (png 画像) を追加したいのですが、方法がわかりません。mutt などに移行する前に、mailx で試してみたいと思います。どうもありがとう

4

2 に答える 2

1

要件が単純な場合は、そのままの Sendmail を使用できます。特にオススメというわけではありませんが、避けたかったのでmutt

# Now that we actually concatenate two files (well, stdin and a file),
# we are no longer eligible for a Useless Use of Cat Award
( cat - body.html <<HERE
Subject: My subject
Mime-Version: 1.0
Content-type: multipart/related; boundary="foooobar"

--foooobar
Content-type: text/html

HERE

cat <<HERE

--foooobar
Content-type: image/png
Content-disposition: inline
Content-transfer-encoding: base64

HERE

base64 image.png

echo; echo '--foooobar--' ) | sendmail -oi $RECIPIENTS

このためのシンプルで標準的なユーティリティがあればいいのにと思いますが、残念ながら、多かれ少なかれ相互に互換性がなく、あいまいなユーティリティが多数あります。繰り返しになりますが、使用できる場合mutt、それはおそらく最も広くサポートされ、期待できる標準ツールです。

于 2014-03-10T18:42:14.750 に答える