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: Closed Last Modified: 2026-11-21 12:27:58
Resolution: Fixed Closed By: serhiy.storchaka
    Closed on: 2026-11-21 12:27:58
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..."
User Comments: serhiy.storchaka added on 2026-11-21 12:27:58:

Reproduced with smtp 1.4.2 (tcllib 1.9) without Trf: the body was written without a final CRLF, so the terminating "." ended up on the last body line and the server kept waiting. Fixed by [fce6d51b45] (smtp 1.4.3, tcllib 1.10, same cause as #827436). Both messages from the example are delivered on 8.6 and 9.1.