[ZCM] [ZC] 2152/ 1 Request "MailHost.send_simple()"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Wed Jul 19 10:51:10 EDT 2006


Issue #2152 Update (Request) "MailHost.send_simple()"
 Status Pending, Zope/bug+solution medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/2152

==============================================================
= Request - Entry #1 by kkoegler on Jul 19, 2006 10:51 am

As outlined in http://mail.zope.org/pipermail/zope/2006-July/167243.html, MailHost.send_simple() doesn't support multiple recipients as comma separated string, nor lists (contrary to the documentation). The following diff enables lists, but not comma separated strings, because parsing them correctly is non-trivial (since RFC822-addresses can contain comments which can contain commas). 

# diff -u MailHost.py.orig MailHost.py
--- MailHost.py.orig    Wed Jul 19 16:26:29 2006
+++ MailHost.py Wed Jul 19 16:30:09 2006
@@ -14,6 +14,8 @@
 $Id: MailHost.py,v 1.79.12.3 2003/11/17 22:34:09 tseaver Exp $"""
 __version__ = "$Revision: 1.79.12.3 $"[11:-2]

+import types
+
 from Globals import Persistent, DTMLFile, InitializeClass
 from smtplib import SMTP
 from AccessControl.Role import RoleManager
@@ -132,11 +134,13 @@

     security.declareProtected( use_mailhost_services, 'simple_send' )
     def simple_send(self, mto, mfrom, subject, body):
-        body="From: %s\nTo: %s\nSubject: %s\n\n%s" % (
-            mfrom, mto, subject, body)
-
-        self._send( mfrom, mto, 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)

     security.declarePrivate( '_send' )
     def _send( self, mfrom, mto, messageText ):
# diff -u help/MailHost.py.orig help/MailHost.py
--- help/MailHost.py.orig       Wed Jul 19 16:41:01 2006
+++ help/MailHost.py    Wed Jul 19 16:41:24 2006
@@ -62,7 +62,7 @@
         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.
+            mto -- A single address or a list of recipient(s) of the message.

             mfrom -- The address of the message sender.


==============================================================



More information about the Zope-Collector-Monitor mailing list