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:

         A commaseparated string or list of recipient(s) of the message.
         The address of the message sender.
         The subject of the message.
         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:


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


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)
       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(',')

Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to