Html 使用带有颜色编码的sendmail

Html 使用带有颜色编码的sendmail,html,tcl,sendmail,background-color,Html,Tcl,Sendmail,Background Color,我试图在tcl中通过'sendmail'的帮助发送带有附件的电子邮件,我使用以下代码 set msg {From: dinesh} append msg \n "To: " [join $recipient_list ,] append msg \n "Cc: " [join $cc_list ,] append msg \n "Subject: $subject" append msg \n\n $body exec /usr/lib/sendmail -oi -t << $ms

我试图在tcl中通过
'sendmail'
的帮助发送带有附件的电子邮件,我使用以下代码

set msg {From: dinesh}
append msg \n "To: " [join $recipient_list ,]
append msg \n "Cc: " [join $cc_list ,]
append msg \n "Subject: $subject"
append msg \n\n $body

exec /usr/lib/sendmail -oi -t << $msg
set msg{From:dinesh}
将消息\n“附加到:“[加入$recipient\u列表,]
附加消息\n“Cc:[加入$Cc\u列表,]
追加消息\n“主题:$Subject”
附加消息\n\n$body

exec/usr/lib/sendmail-oi-t要发送被另一端解释为具有样式的电子邮件,必须以支持嵌入样式的格式(如HTML)发送消息正文,并且必须发送MIME头,说明正文就是该格式(即,HTML内容与内容类型
text/HTML
)相关联

组装MIME消息相当烦人,但有一些方法可以帮助您:

包需要mime
#构建身体
set html“测试这是对MIME消息合成的测试。”
设置标记[mime::initialize-规范文本/html-字符串$html]
#添加电子邮件的标题
mime::来自dinesh的setheader$token
mime::setheader$token[加入$recipient_列表,]
mime::setheader$token Cc[加入$Cc_列表,]
mime::setheader$token Subject$Subject
#序列化为字符串
设置消息[mime::buildmessage$token]
mime::finalize$token
###如何检查是否正常:放置$message
#发送消息

exec/usr/lib/sendmail-oi-t发送带有内容标题的邮件
内容类型:text/html
在你问之前,我讨厌
-canonical
选项的命名。我认为这非常不明显。
package require mime

# Construct the body
set html "<h1>A test</h1>This is <i>a test</i> of MIME message composition."
set token [mime::initialize -canonical text/html -string $html]

# Add in the headers for email
mime::setheader $token From dinesh
mime::setheader $token To [join $recipient_list ,]
mime::setheader $token Cc [join $cc_list ,]
mime::setheader $token Subject $subject

# Serialize to a string
set message [mime::buildmessage $token]
mime::finalize $token
### How to check for sanity:   puts $message

# Send the message
exec /usr/lib/sendmail -oi -t << $message