On 7/17/06, John Schinnerer <[EMAIL PROTECTED]> wrote:
The Zope (2.7.5) API docs for MailHost show this for simple_send:
--------------
simple_send(self, mto, mfrom, subject, body):
Sends a message. Only To:, From: and Subject: headers can be set.
The arguments are:
mto
A commaseparated string or list of recipient(s) of the message.
mfrom
The address of the message sender.
subject
The subject of the message.
body
The body of the message.
--------------
a bit digging in the code on one of my installations (2.7.4) revealed,
that Zope more or less directly invokes SMTP.sendmail from smtplib
of python. quote from the docs: "a list of RFC 822 to-address strings
(a bare string will be treated as a list with 1 address)"
this seems a small bug in zope (either implementation or
documentation). for a fix, make the list yourself:
yourstring.split(',')
this _could_ break the RFC-conformity of the to-header of the message,
because simple_send builds the body of the message like this:
body="From: %s\nTo: %s\nSubject: %s\n\n%s" \
% (mfrom, mto, subject, body)
which would result in
To: ['[EMAIL PROTECTED]','[EMAIL PROTECTED]','[EMAIL PROTECTED]']
which makes the message unroutable.
I suggest this code for MailBase.simple_send() (Malhost.py):
import types # this belongs into the import section
[.. snip, in simple_send: ..]
def simple_send(self, mto, mfrom, subject, body):
if type(mto)==types.ListType:
body = "From: %s\nTo: %s\nSubject: %s\n\n%s" \
% (mfrom, ','.join(mto), subject, body)
else:
body = "From: %s\nTo: %s\nSubject: %s\n\n%s" \
% (mfrom, mto, subject, body)
self._send(mfrom, mto, body)
and change the documentation to accept lists and strings,
because parsing a comma-separated list of true rfc-822
addresses is far more complicarted than somestring.split(',')
--knitti
_______________________________________________
Zope maillist - Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )