I automate a network switch using Tcl and expect scripts on my Fedora 12. The test logs and result with attachments are sent to an email inbox (office 365)-browser and outlook modes.
I would like to know if there is a way to make the color fonts appear in my email using TCL or shell script.
For example in the report sent to email, the text "Passed" should appear in Green-bold and the font "failed" must appear in Red-bold. Will tput be useful? Please help. Thanks in advance.
So, here is a simple script that I use to send mails (you might need to provide a username/password for smtp::sendmessage
)
set textpart [::mime::initialize -canonical text/plain -string {Hello World}]
set htmlpart [::mime::initialize -canonical text/html -string {<font color="green">Hello World</font>}]
set tok [::mime::initialize -canonical multipart/alternative -parts [list $textpart $htmlpart] -header {From test@example.com}]
::mime::setheader $tok Subject {Hello World}
::smtp::sendmessage $tok -servers smtp.example.com -recipients recipient@example.com -originator test@example.com
::mime::finalize $tok -subordinates all
Some notes:
multipart/mixed
, (build it like the multipart/alternative
), the first part of it should be the message (your multipart/alternative
) the other parts are the attachments.