package require smtp package require mime #---------------------------------------------------------------- winSendMail # # Sends email to the specified list of addresses # # INPUT: to - A list of email addrs of the primary recipients # cc - A list of email addrs of BCC recipients # bcc - A list of email addrs of BCC recipients # subj - The subject line # body - The message body (if this string looks like a # file - Flag; 0 if body is just text, 1 if body is path to file # # RETURN: 1 - Send failed # 0 - Send succeeded # # PUBLIC # proc winSendMail { to cc bcc subject body { file 0 } } { global TtMailBox if { $file } { set filename $body; set body [ readFile $body ] } set server set user set passwd set fullname set emailaddr set token [ mime::initialize -canonical text/plain -string $body ] mime::setheader $token Subject $subject mime::setheader $token Date [clock format [clock seconds] -format "%a, %d %b %Y %H:%M:%S -0800"] if { $cc != "" } { mime::setheader $token cc $cc -mode append } if { $bcc != "" } { mime::setheader $token bcc $bcc -mode append } set unmailed [ smtp::sendmessage $token -recipients $to -servers $server -username $user -password $passwd -originator "\"$fullname\" <$emailaddr>" ] mime::finalize $token if { $unmailed != "" } { set TtMailBox(ERROR) $unmailed; return 1 } return 0 }