Tk Library Source Code

View Ticket
Login
Ticket UUID: 1027730
Title: Covering case: undetectable originator
Type: Patch Version: None
Submitter: csan Created on: 2004-09-14 07:12:04
Subsystem: smtp Assigned To: mrose
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2005-09-05 18:46:25
Resolution: Fixed Closed By: patthoyts
    Closed on: 2005-09-05 11:46:25
Description:
I bumped into this case while trying to find out why
smtp cannot send mail from a Rivet script. 

I was getting the following error:

-------- cut here --------
can't read "aprops(error)": no such element in array
    while executing
"if {$aprops(error) != ""} {
            error "error in $who: $aprops(error)"
        }"
    (procedure "smtp::sendmessage" line 152)
    invoked from within
"smtp::sendmessage $token -recipients $recipient
-servers $email_server"
    (procedure "send_simple_message" line 8)
-------- cut here --------

I have found otu that while the too many senders
(originators) case was covered:

-------- cut here --------
set addrs [::mime::parseaddress $originator]
if {[llength $addrs] > 1} {
            error "too many mailboxes in $who: $originator"
        }
-------- cut here --------

the no sender (actually, undetectable sender) case was
not covered.
I am suggesting the following three lines be added to
smtp.tcl to cover the no sender case and thus give a
more comprehensive error message.

-------- cut here --------
# diff -u /usr/lib/tcllib1.6/mime/smtp.tcl~
/usr/lib/tcllib1.6/mime/smtp.tcl---
/usr/lib/tcllib1.6/mime/smtp.tcl~2004-05-27
03:17:10.000000000 +0200+++
/usr/lib/tcllib1.6/mime/smtp.tcl2004-09-13
17:41:59.000000000 +0200@@ -252,6 +252,9 @@        
if {[llength $addrs] > 1} {             error "too
many mailboxes in $who: $originator"         }+     
  if {[llength $addrs] == 0} {+            error
"could not detect sender address"+        }        
array set aprops [lindex $addrs 0]         if
{$aprops(error) != ""} {             error "error in
$who: $aprops(error)"
-------- cut here --------

Optionally, the following note could be added to
smtp(3tcl):

-------- cut here --------
# diff -u smtp.3tcl~ smtp.3tcl
--- smtp.3tcl~2004-09-14 09:03:28.000000000 +0200
+++ smtp.3tcl2004-09-14 09:10:18.000000000 +0200
@@ -314,6 +314,11 @@
 added to the outgoing message as necessary to ensure
that a valid
 822-style message is sent.
 .sp
+NOTE: it could be necessary to specify the originator
address with
+the -originator option, especially when
::smtp::sendmessage is used
+in server-side scripts such as e.g. Rivet scripts, in
which case it
+could happen that the originator address cannot be
detected.
+.sp
 The command returns a list indicating which recipients
were
 unacceptable to the SMTP server. Each element of the
list is another
 list, containing the address, an SMTP error code, and
a textual
-------- cut here --------

Thank you.
User Comments: patthoyts added on 2005-09-05 18:46:25:
Logged In: YES 
user_id=202636

Fixed in revision 1.43 as part of some other work. All
places that set the error array from the result now preload
the array with a default error message.

andreas_kupries added on 2004-09-30 04:48:51:
Logged In: YES 
user_id=75003

Please attach your diffs to the report, instead of inlining
them. Also, do you have one or more demo script we could add
to the testsuite as new test cases ?

Basically I see that there is a problem, but I have no idea
how to reproduce it.