mutt 发送html,如何在html中使用html和body从unix mutt客户端发送邮件?

我怀疑你必须自己制作身体。请注意,混合主体的content_type是multipart/alternative

我发现这个问题很有趣。这是我对此采取:

#!/bin/sh

# using mutt, send a mixed multipart text and html message:

usage() {

echo "error: $1"

echo "usage: $(basename $0) -t textfile -h htmlfile -s subject -r recipient"

exit 1

}

textfile=""

htmlfile=""

subject=""

recipient=""

while getopts "t:h:s:r:" opt; do

case $opt in

t) textfile="$OPTARG" ;;

h) htmlfile="$OPTARG" ;;

s) subject="$OPTARG" ;;

r) recipient="$OPTARG" ;;

?) usage "invalid option: -$OPTARG" ;;

esac

done

shift $((OPTIND-1))

[ -z "$textfile" ] && usage "no textfile specified"

[ -z "$htmlfile" ] && usage "no htmlfile specified"

[ -z "$recipient" ] && usage "no recipient specified"

[ ! -f "$textfile" ] && usage "no such file: $textfile"

[ ! -f "$htmlfile" ] && usage "no such file: $htmlfile"

boundary=$(openssl rand -hex 24)

content_type="Content-type: multipart/alternative; boundary=$boundary"

##

body=$(cat - << END

--$boundary

Content-Type: text/plain; charset=ISO-8859-1

$(cat "$textfile")

--$boundary

Content-Type: text/html; charset=ISO-8859-1

$(cat "$htmlfile")

--$boundary

END

)

##

echo "$body" | mutt -e "myhdr $content_type" -s "$subject" "$recipient"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值