Tcl Library Source Code

View Ticket
Login
Ticket UUID: 1709334
Title: Missing trailing newline hangs sendmessage
Type: Bug Version: None
Submitter: dnew Created on: 2007-04-28 18:10:53
Subsystem: smtp Assigned To: mrose
Priority: 5 Medium Severity:
Status: Open Last Modified: 2007-04-28 18:10:53
Resolution: None Closed By:
    Closed on:
Description:
I'm not sure if this is a mime problem or an smtp problem, but...

If you use the MIME package to create a text/plain without a newline on the end, then use smtp::sendmessage to send it, it appears to hang after sending the message in the DATA command. I suspect the "close the data" period is winding up at the end of the final line instead of at the start of a line by itself.

Sample code:
# The first message goes
# The second message hangs.

package require mime
package require smtp

proc sendmail {from to bcc subject body {queue 1}} {
  set mail [mime::initialize -canonical text/plain -string $body]
  smtp::sendmessage $mail \
    -debug 1 \
    -header [list From $from] \
    -header [list To $to] \
    -header [list BCC $bcc] \
    -header [list Subject $subject] 
  mime::finalize $mail
}

puts "Testing with newline..."
sendmail "[email protected]" "[email protected]"  "" \
  "Subject One" "Test body\nNewline present\n"
puts "Message one sent...\n"
after 10000
puts "Testing without newline..."
sendmail "[email protected]" "[email protected]"  "" \
  "Subject two" "Test body\nNewline absent"
puts "Message two sent..."