To send email that will be interpreted by the other end as having styling, you've got to send the message body in a format that supports embedded styling (such as HTML) and you've got to send the MIME headers that say that the body is that format (i.e., HTML content is associated with the content type text/html
).
Assembling a MIME message is rather annoying, but there's a package in Tcllib to help:
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
You could use the smtp
package from Tcllib to do the sending too (and it integrates well with the mime
package) but if exec /usr/lib/sendmail
works, stick with it.
Be aware that showing the resulting message as styled requires the coöperation of the receiving client. Also be aware that it's conventional to send the content unstyled as well, as plain text in a multi-part message. Assembling such complex things is when using the mime
package helps a lot.