smtp on Windows: "key message-id not in header"

28 views
Skip to first unread message

EL

unread,
May 7, 2008, 5:57:41 AM5/7/08
to
Hi,

I can not send mail from windows with the mime/smtp package. the example
in the documentation (http://tcllib.sourceforge.net/doc/smtp.html) does
not work and gives the following error:

key message-id not in header
while executing
"error "key $mixed not in header""
("default" arm line 5)
invoked from within
"switch -- $key {
"" {
set result ""
foreach lower $state(lowerL) mixed $state(mixedL) {
lappend result..."
(procedure "::mime::getheader" line 7)
invoked from within
"::mime::getheader $part ${message-idL} "
invoked from within
...

I try to send via a public smtp server (smtp.googlemail.com) using
-username and -password. On Mac OS X it works, with exactly the same
code, smtp server and -username/-password.

Is this a bug, or is there any windows specific thing that must be
considered?


Thanks in advance

--
Eckhard

Bezoar

unread,
May 7, 2008, 1:17:36 PM5/7/08
to

Have you tried to set the header key message-id using the -header
option to
::smtp::sendmessage ?

Carl

Twylite

unread,
May 8, 2008, 3:52:46 AM5/8/08
to
On May 7, 11:57 am, EL <eckhardnos...@gmx.de> wrote:
> I can not send mail from windows with the mime/smtp package. the example
> in the documentation (http://tcllib.sourceforge.net/doc/smtp.html) does
> not work and gives the following error:
>
> key message-id not in header

We've seen that when using SMTP AUTH in conjunction with MS Exchange.
The problem was related to the use of mime::setheader instead of
including the headers as options to smtp::sendmessage. Not sure _why_
this was a problem, it just was.

This code works for us:

package require mime
package require smtp

proc send_email {from to subject body} {

set opts {}
lappend opts -servers [list 10.0.0.1]
lappend opts -ports [list 25]
lappend opts -username user
lappend opts -password pass
lappend opts -header [list "Subject" $subject]
lappend opts -header [list "From" $from]
lappend opts -header [list "To" $to]

set mime_msg [mime::initialize -canonical "text/plain" -encoding
"7bit" \
-string $body]

smtp::sendmessage $mime_msg {*}$opts -queue false -atleastone false -
usetls false

mime::finalize $mime_msg

}

send_email "Twylite <twylite@mydomain>" "Person <someone@somewhere>"
"Test" {
This is my mail message.
}


Regards,
Twylite

EL

unread,
May 8, 2008, 8:48:48 AM5/8/08
to
Bezoar schrieb:

> Have you tried to set the header key message-id using the -header
> option to
> ::smtp::sendmessage ?

I have no idea what to set for the header key message-id... thought that
this field is filled automatically with the correct value?

--
Eckhard

Bezoar

unread,
May 8, 2008, 1:24:49 PM5/8/08
to

You know thats a good question! I just looked at some mail I've got
and
it does appear to be something that would be set by the server but it
is
a message id that is generated by the client for example
<0210170...@testingsmtp.com>.
I imagine that the number you use is a hash of the
subject,receipients etc. and the
part following the @ is a domain. I could see that the smtp package
automatically generating
the number portion but it may not be able to determine domain, and
this may be where your
problem is. In mean time set the item in header and see if it works.
Can't hurt.

Carl

EL

unread,
May 8, 2008, 1:41:05 PM5/8/08
to
Bezoar schrieb:

>
> You know thats a good question! I just looked at some mail I've got
> and
> it does appear to be something that would be set by the server but it
> is
> a message id that is generated by the client for example
> <0210170...@testingsmtp.com>.
> I imagine that the number you use is a hash of the
> subject,receipients etc. and the
> part following the @ is a domain. I could see that the smtp package
> automatically generating
> the number portion but it may not be able to determine domain, and
> this may be where your
> problem is. In mean time set the item in header and see if it works.
> Can't hurt.

Thanks... I have figured out that it is probably due to restrictions in
our company network - you can not access smtp. Of course I could have
thought about this before.
On my virtual windows machine at home it works.

Anyway, I'd expected a more meaningful error message in these cases.
Something like "server not reachable" would have been better.


--
Eckhard

USCode

unread,
May 9, 2008, 2:14:16 PM5/9/08
to
Twylite wrote:
> This code works for us:
>
> package require mime
> package require smtp
>
> proc send_email {from to subject body} {
>
> set opts {}
> lappend opts -servers [list 10.0.0.1]
> lappend opts -ports [list 25]
> lappend opts -username user
> lappend opts -password pass
> lappend opts -header [list "Subject" $subject]
> lappend opts -header [list "From" $from]
> lappend opts -header [list "To" $to]
>
> set mime_msg [mime::initialize -canonical "text/plain" -encoding
> "7bit" \
> -string $body]
>
> smtp::sendmessage $mime_msg {*}$opts -queue false -atleastone false -
> usetls false
>
> mime::finalize $mime_msg
>
> }
>
> send_email "Twylite <twylite@mydomain>" "Person <someone@somewhere>"
> "Test" {
> This is my mail message.
> }
>

Twylite, are all the 'list' commands used when you're lappending $opts
there in case the user inadvertently enters a '-' option in a var (such
as $subject, $from, etc.) so they don't get evaluated as an option?
Thanks

Reply all
Reply to author
Forward
0 new messages