vaichidrewar
vaichidrewar

Reputation: 9621

How to use sendmail from Tcl

How do I send mail to multiple recipients in To and Cc using sendmail in Tcl?

Upvotes: 3

Views: 10451

Answers (3)

hsmit
hsmit

Reputation: 3906

This will also work:

echo "Subject: test" | /usr/lib/sendmail -v [email protected]

Upvotes: 0

glenn jackman
glenn jackman

Reputation: 246744

If you want to actually use sendmail, build up the message as a string and use the exec << option to pass it to sendmail's stdin:

set msg {From: someone}
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

Upvotes: 4

bmk
bmk

Reputation: 14137

You can use the smtp package, see e.g.: SMTP package docu or Wiki.

I think you could e.g. do:

  package require smtp
  package require mime

  set token [mime::initialize -canonical text/plain -string $body]
  smtp::sendmessage $token \
          -header [list Subject $subject] \
          -header [list To [join $recipient_list ","]] \
          -header [list Cc [join $cc_list ","]]
  mime::finalize $token

Upvotes: 7

Related Questions