*** smtpd.tcl.old	Wed Dec 11 17:26:52 2002
--- smtpd.tcl	Wed Dec 11 17:31:05 2002
*************** proc smtpd::start {{myaddr {}} {port 25}
*** 99,105 ****
--- 99,108 ----
      }
  
      if {$myaddr != {}} {
+         set options(myaddr) "$myaddr"
          set myaddr "-myaddr $myaddr"
+     } else {
+         set options(myaddr) [info hostname]
      }
      set options(socket) [eval socket \
                               -server [namespace current]::accept $myaddr $port]
*************** proc smtpd::accept {channel client_addr 
*** 158,164 ****
      if {$accepted} {
          # Accept the connection
          log::log notice "connect from $client_addr:$client_port on $channel"
!         puts $channel "220 [info hostname] tcllib smtpd $version; [timestamp]"
      }
      
      return
--- 161,167 ----
      if {$accepted} {
          # Accept the connection
          log::log notice "connect from $client_addr:$client_port on $channel"
!         puts $channel "220 $options(myaddr) tcllib smtpd $version; [timestamp]"
      }
      
      return
*************** proc smtpd::service {channel} {
*** 213,219 ****
  
      # If we are handling a DATA section, keep looking for the end of data.
      if {[state $channel indata] } {
!         if {$cmdline == "."} {
              state $channel indata 0
              fconfigure $channel -translation crlf
              puts $channel "250 [state $channel id]\
--- 216,223 ----
  
      # If we are handling a DATA section, keep looking for the end of data.
      if {[state $channel indata] } {
!         #Patched to keep track of line termination (cr, lf or cr/lf)
!         if {$cmdline == "." || $cmdline == ".\r" } {
              state $channel indata 0
              fconfigure $channel -translation crlf
              puts $channel "250 [state $channel id]\
*************** proc smtpd::deliver {channel} {
*** 343,348 ****
--- 347,354 ----
  #   RFC2821 4.1.1.1
  #
  proc smtpd::HELO {channel line} {
+     variable options
+ 
      if {[state $channel domain] != {}} {
          puts $channel "503 bad sequence of commands"
          log::log debug "HELO received out of sequence."
*************** proc smtpd::HELO {channel line} {
*** 355,361 ****
          log::log debug "HELO received \"$line\""
          return
      }
!     puts $channel "250-[info hostname] Hello $domain\
                       \[[state $channel client_addr]\], pleased to meet you"
      puts $channel "250 Ready for mail."
      state $channel domain $domain
--- 361,367 ----
          log::log debug "HELO received \"$line\""
          return
      }
!     puts $channel "250-$options(myaddr) Hello $domain\
                       \[[state $channel client_addr]\], pleased to meet you"
      puts $channel "250 Ready for mail."
      state $channel domain $domain
*************** proc smtpd::HELO {channel line} {
*** 368,373 ****
--- 374,381 ----
  # Reference:
  #   RFC2821 4.1.1.1
  proc smtpd::EHLO {channel line} {
+     variable options
+ 
      if {[state $channel domain] != {}} {
          puts $channel "503 bad sequence of commands"
          log::log debug "EHLO received out of sequence."
*************** proc smtpd::EHLO {channel line} {
*** 380,386 ****
          log::log debug "EHLO received \"$line\""
          return
      }
!     puts $channel "250-[info hostname] Hello $domain\
                       \[[state $channel client_addr]\], pleased to meet you"
      puts $channel "250 Ready for mail."
      state $channel domain $domain
--- 388,394 ----
          log::log debug "EHLO received \"$line\""
          return
      }
!     puts $channel "250-$options(myaddr) Hello $domain\
                       \[[state $channel client_addr]\], pleased to meet you"
      puts $channel "250 Ready for mail."
      state $channel domain $domain
*************** proc smtpd::RCPT {channel line} {
*** 490,495 ****
--- 498,505 ----
  #
  proc smtpd::DATA {channel line} {
      variable version
+     variable options
+ 
      if { [state $channel from] != {} && [state $channel to] != {} } {
          puts $channel "354 Enter mail, end with \".\" on a line by itself"
          state $channel id [uid]
*************** proc smtpd::DATA {channel line} {
*** 497,505 ****
          eval array set sndr [mime::parseaddress [state $channel from]]
  
          set trace "Received: from [state $channel domain] \[[state $channel client_addr]\]\n\
!               \tby [info hostname] ($version) id [state $channel id]; [timestamp]"
          state $channel data [list $trace]
!         fconfigure $channel -translation auto
      } else {
          puts $channel "503 bad sequence of commands"
      }
--- 507,516 ----
          eval array set sndr [mime::parseaddress [state $channel from]]
  
          set trace "Received: from [state $channel domain] \[[state $channel client_addr]\]\n\
!               \tby $options(myaddr) ($version) id [state $channel id]; [timestamp]"
          state $channel data [list $trace]
!         #Patch to keep track of line termination (cr, lf or cr/lf)
! 	fconfigure $channel -translation lf
      } else {
          puts $channel "503 bad sequence of commands"
      }
*************** proc smtpd::NOOP {channel line} {
*** 581,588 ****
  #   a QUIT message.
  #
  proc smtpd::QUIT {channel line} {
      log::log debug "QUIT on $channel"
!     puts $channel "221 [info hostname] Service closing transmission channel"
      close $channel
          
      # cleanup the session state array.
--- 592,601 ----
  #   a QUIT message.
  #
  proc smtpd::QUIT {channel line} {
+     variable options
+ 
      log::log debug "QUIT on $channel"
!     puts $channel "221 $options(myaddr) Service closing transmission channel"
      close $channel
          
      # cleanup the session state array.
