2011-03-16 70 views

回答

4

如果你想實際使用sendmail,建立消息作爲字符串,用exec <<選項,將它傳遞給sendmail的標準輸入:

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 
+1

可以使用Tcllib啞劇打包生成消息。特別參見'mime :: setheader'和'mime :: buildmessage'。 http://tcllib.sourceforge.net/doc/mime.html – 2011-03-17 09:05:59

+0

它說'關鍵字'味精'不期望'知道爲什麼。? – Saif 2015-11-03 08:42:48

7

您可以使用smtp包,請參閱例如:SMTP package docuWiki

我想你可以例如這樣做:

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 
+0

您也可以通過傳遞一個較長的列表或字典指定一個選項的標題:'-header [列表主題$ SUBJ爲[加入$ recips「」]]' – 2011-03-16 10:09:47