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
Have you tried to set the header key message-id using the -header
option to
::smtp::sendmessage ?
Carl
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
> 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
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
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
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