Forum OpenACS Q&A: Re: ns_sendmail replacement?

Collapse
Posted by Tilmann Singer on
Here's a patch against the original sendmail.tcl that hopefully includes all corrections. I'll try to submit it on aolserver's bug tracker on sourceforge (last time I tried it was not working due to timeouts).

*** root/aolserver/tcl/sendmail.tcl	Fri Aug 11 22:04:10 2000
--- aolserver/modules/tcl/sendmail.tcl	Fri Jan 17 12:34:59 2003
***************
*** 96,120 ****
  	set smtpport 25
      }
  
-     ## Extract "from" email address
-     if [regexp {.*<(.*)>} $from ig address] {
- 	set from $address
-     }
-     
      set tolist [list]
      foreach toaddr $tolist_in {
- 	if [regexp {.*<(.*)>} $toaddr ig address] {
- 	    set toaddr $address
- 	}
  	lappend tolist "[string trim $toaddr]"
      }
      
      set bcclist [list]
      if ![string match "" $bcclist_in] {
  	foreach bccaddr $bcclist_in {
- 	    if [regexp {.*<(.*)>} $bccaddr ig address] {
- 		set bccaddr $address
- 	    }
  	    lappend bcclist "[string trim $bccaddr]"
  	}
      }
--- 96,109 ----
***************
*** 160,165 ****
--- 149,157 ----
      set rfp [lindex $sock 0]
      set wfp [lindex $sock 1]
  
+     ## Strip "from" email address
+     regexp {.*<(.*)>} $from ig from
+ 
      ## Perform the SMTP conversation
      if { [catch {
          _ns_smtp_recv $rfp 220 $timeout
***************
*** 168,183 ****
  	_ns_smtp_send $wfp "MAIL FROM:<$from>" $timeout
  	_ns_smtp_recv $rfp 250 $timeout
  	
! 	## Loop through To list via multiple RCPT TO lines
! 	foreach toto $tolist {
! 	    _ns_smtp_send $wfp "RCPT TO:<$toto>" $timeout
! 	    _ns_smtp_recv $rfp 250 $timeout	
! 	}
! 	
! 	## Loop through BCC list via multiple RCPT TO lines
  	## A BCC should never, ever appear in the header.  Ever.  Not even.
! 	foreach bccto $bcclist {
! 	    _ns_smtp_send $wfp "RCPT TO:<$bccto>" $timeout
  	    _ns_smtp_recv $rfp 250 $timeout
  	}
  	
--- 160,173 ----
          _ns_smtp_send $wfp "MAIL FROM:<$from>" $timeout
          _ns_smtp_recv $rfp 250 $timeout
          
!         ## Loop through To and Bcc list via multiple RCPT TO lines
          ## A BCC should never, ever appear in the header.  Ever.  Not even.
!         foreach toto [concat $tolist $bcclist] {
! 
!             # Transform "Fritz <fritz@foo.com>" into "fritz@foo.com".
!             regexp {.*<(.*)>} $toto ig toto
! 
!             _ns_smtp_send $wfp "RCPT TO:<$toto>" $timeout
              _ns_smtp_recv $rfp 250 $timeout    
          }