Version 0 of Sendmail

Updated 1999-04-21 12:44:41
     ## Authors: Jonathan Perret and Gerald Lester                   ##
     ## Purpose: This sends SMTP mail        
     ##    Date: December 27, 1995                                   ##
     ##################################################################

     ## Send SMTP to mail host.
     proc sendmail {smtphost toList from subject body {trace 0}} {
        if $trace then {
                puts stdout "Connecting to $smtphost:25"
        }
        set sockid [socket $smtphost 25]
        puts $sockid "MAIL From:<$from>"
        flush $sockid
        set result [gets $sockid]
        if $trace then {
                puts stdout "MAIL From:<$from>\n\t$result"
        }
        foreach to $toList {
            puts $sockid "RCPT To:<$to>"
            flush $sockid
        }
        set result [gets $sockid]
        if $trace then {
                puts stdout "RCPT To:<$to>\n\t$result"
        }
        puts  $sockid "DATA "
        flush $sockid
        set result [gets  $sockid]
        if $trace then {
                puts stdout "DATA \n\t$result"
        }
        puts  $sockid "From: <$from>"
        puts  $sockid "To: <$to>"
        puts  $sockid "Subject: $subject"
        puts  $sockid "\n"
        foreach line [split $body  "\n"] {
                puts  $sockid "[join $line]"
        }
        puts  $sockid "."
        puts  $sockid "QUIT"
        flush $sockid
        set result [gets  $sockid]
        if $trace then {
                puts stdout "QUIT\n\t$result"
        }
        close $sockid 
        return;
     }