changeset 1360:aa7e4e8b14be

allow additional control over the roundupdb email sending... ...explicit cc addresses, different from address and different nosy list property. (thanks John Rouillard)
author Richard Jones <richard@users.sourceforge.net>
date Sun, 12 Jan 2003 00:41:27 +0000
parents ebfd8dd1cce7
children b94cc62090be
files CHANGES.txt doc/customizing.txt roundup/roundupdb.py roundup/templates/classic/config.py roundup/templates/minimal/config.py
diffstat 5 files changed, 89 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Sun Jan 12 00:03:11 2003 +0000
+++ b/CHANGES.txt	Sun Jan 12 00:41:27 2003 +0000
@@ -5,6 +5,9 @@
 - better hyperlinking in web message texts
 - support setting of properties on message and file through web and
   email interface (thanks John Rouillard)
+- allow additional control over the roundupdb email sending (explicit
+  cc addresses, different from address and different nosy list property)
+  (thanks John Rouillard)
 
 
 2003-01-10 0.5.4
--- a/doc/customizing.txt	Sun Jan 12 00:03:11 2003 +0000
+++ b/doc/customizing.txt	Sun Jan 12 00:41:27 2003 +0000
@@ -2,7 +2,7 @@
 Customising Roundup
 ===================
 
-:Version: $Revision: 1.68 $
+:Version: $Revision: 1.69 $
 
 .. This document borrows from the ZopeBook section on ZPT. The original is at:
    http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -107,15 +107,25 @@
  The email address that e-mail sent to roundup should go to. Think of it as the
  tracker's personal e-mail address.
 
-**TRACKER_WEB** - ``'http://your.tracker.url.example/'``
+**TRACKER_WEB** - ``'http://tracker.example/cgi-bin/roundup.cgi/bugs/'``
  The web address that the tracker is viewable at. This will be included in
- information sent to users of the tracker. The URL must include the cgi-bin
- part or anything else that is required to get to the home page of the
- tracker. You must include a trailing '/' in the URL.
+ information sent to users of the tracker. The URL **must** include the
+ cgi-bin part or anything else that is required to get to the home page of
+ the tracker. You **must** include a trailing '/' in the URL.
 
 **ADMIN_EMAIL** - ``'roundup-admin@%s'%MAIL_DOMAIN``
  The email address that roundup will complain to if it runs into trouble.
 
+**EMAIL_FROM_TAG** - ``''``
+ Additional text to include in the "name" part of the ``From:`` address used
+ in nosy messages. If the sending user is "Foo Bar", the ``From:`` line is
+ usually::
+     "Foo Bar" <issue_tracker@tracker.example>
+
+ the EMAIL_FROM_TAG goes inside the "Foo Bar" quotes like so::
+
+    "Foo Bar EMAIL_FROM_TAG" <issue_tracker@tracker.example>
+
 **MESSAGES_TO_AUTHOR** - ``'yes'`` or``'no'``
  Send nosy messages to the author of the message.
 
@@ -172,12 +182,22 @@
     # The email address that mail to roundup should go to
     TRACKER_EMAIL = 'issue_tracker@%s'%MAIL_DOMAIN
 
-    # The web address that the tracker is viewable at
-    TRACKER_WEB = 'http://your.tracker.url.example/'
+    # The web address that the tracker is viewable at. This will be included in
+    # information sent to users of the tracker. The URL MUST include the cgi-bin
+    # part or anything else that is required to get to the home page of the
+    # tracker. You MUST include a trailing '/' in the URL.
+    TRACKER_WEB = 'http://tracker.example/cgi-bin/roundup.cgi/bugs/'
 
     # The email address that roundup will complain to if it runs into trouble
     ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN
 
+    # Additional text to include in the "name" part of the From: address used
+    # in nosy messages. If the sending user is "Foo Bar", the From: line is
+    # usually: "Foo Bar" <issue_tracker@tracker.example>
+    # the EMAIL_FROM_TAG goes inside the "Foo Bar" quotes like so:
+    #    "Foo Bar EMAIL_FROM_TAG" <issue_tracker@tracker.example>
+    EMAIL_FROM_TAG = ""
+
     # Send nosy messages to the author of the message
     MESSAGES_TO_AUTHOR = 'no'           # either 'yes' or 'no'
 
@@ -208,6 +228,14 @@
     MAIL_DEFAULT_CLASS = 'issue'   # use "issue" class by default
     #MAIL_DEFAULT_CLASS = ''        # disable (or just comment the var out)
 
+    # 
+    # SECURITY DEFINITIONS
+    #
+    # define the Roles that a user gets when they register with the tracker
+    # these are a comma-separated string of role names (e.g. 'Admin,User')
+    NEW_WEB_USER_ROLES = 'User'
+    NEW_EMAIL_USER_ROLES = 'User'
+
 Tracker Schema
 ==============
 
--- a/roundup/roundupdb.py	Sun Jan 12 00:03:11 2003 +0000
+++ b/roundup/roundupdb.py	Sun Jan 12 00:41:27 2003 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: roundupdb.py,v 1.75 2002-12-11 01:52:20 richard Exp $
+# $Id: roundupdb.py,v 1.76 2003-01-12 00:41:26 richard Exp $
 
 __doc__ = """
 Extending hyperdb with types specific to issue-tracking.
@@ -87,7 +87,8 @@
         appended to the "messages" field of the specified issue.
         """
 
-    def nosymessage(self, nodeid, msgid, oldvalues):
+    def nosymessage(self, nodeid, msgid, oldvalues, whichnosy='nosy',
+            from_address=[], cc=[], bcc=[]):
         """Send a message to the members of an issue's nosy list.
 
         The message is sent only to users on the nosy list who are not
@@ -115,8 +116,16 @@
             sendto.append(authid)
         r[authid] = 1
 
+        # now deal with cc people.
+        for cc_userid in cc :
+            if r.has_key(cc_userid):
+                continue
+            # send it to them
+            sendto.append(cc_userid)
+            recipients.append(cc_userid)
+
         # now figure the nosy people who weren't recipients
-        nosy = self.get(nodeid, 'nosy')
+        nosy = self.get(nodeid, whichnosy)
         for nosyid in nosy:
             # Don't send nosy mail to the anonymous user (that user
             # shouldn't appear in the nosy list, but just in case they
@@ -144,12 +153,12 @@
             messages.set(msgid, recipients=recipients)
 
             # send the message
-            self.send_message(nodeid, msgid, note, sendto)
+            self.send_message(nodeid, msgid, note, sendto, from_address)
 
     # backwards compatibility - don't remove
     sendmessage = nosymessage
 
-    def send_message(self, nodeid, msgid, note, sendto):
+    def send_message(self, nodeid, msgid, note, sendto, from_address=None):
         '''Actually send the nominated message from this node to the sendto
            recipients, with the note appended.
         '''
@@ -220,16 +229,23 @@
         # make sure the To line is always the same (for testing mostly)
         sendto.sort()
 
+        # make sure we have a from address
+        if from_address is None:
+            from_address = self.db.config.TRACKER_EMAIL
+
+        # additional bit for after the From: "name"
+        from_tag = getattr(self.db.config, 'EMAIL_FROM_TAG', '')
+        if from_tag:
+            from_tag = ' ' + from_tag
+
         # create the message
         message = cStringIO.StringIO()
         writer = MimeWriter.MimeWriter(message)
         writer.addheader('Subject', '[%s%s] %s'%(cn, nodeid, title))
         writer.addheader('To', ', '.join(sendto))
-        writer.addheader('From', straddr(
-                              (authname, self.db.config.TRACKER_EMAIL) ) )
-        writer.addheader('Reply-To', straddr( 
-                                        (self.db.config.TRACKER_NAME,
-                                         self.db.config.TRACKER_EMAIL) ) )
+        writer.addheader('From', straddr((authname + from_tag, from_address)))
+        writer.addheader('Reply-To', straddr((self.db.config.TRACKER_NAME,
+            from_address)))
         writer.addheader('Date', time.strftime("%a, %d %b %Y %H:%M:%S +0000",
             time.gmtime()))
         writer.addheader('MIME-Version', '1.0')
@@ -282,7 +298,7 @@
 
         # now try to send the message
         if SENDMAILDEBUG:
-            open(SENDMAILDEBUG, 'w').write('FROM: %s\nTO: %s\n%s\n'%(
+            open(SENDMAILDEBUG, 'a').write('FROM: %s\nTO: %s\n%s\n'%(
                 self.db.config.ADMIN_EMAIL,
                 ', '.join(sendto),message.getvalue()))
         else:
--- a/roundup/templates/classic/config.py	Sun Jan 12 00:03:11 2003 +0000
+++ b/roundup/templates/classic/config.py	Sun Jan 12 00:41:27 2003 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: config.py,v 1.6 2002-12-13 22:20:10 richard Exp $
+# $Id: config.py,v 1.7 2003-01-12 00:41:27 richard Exp $
 
 import os
 
@@ -49,13 +49,13 @@
 # The email address that roundup will complain to if it runs into trouble
 ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN
 
-# 
-# SECURITY DEFINITIONS
-#
-# define the Roles that a user gets when they register with the tracker
-# these are a comma-separated string of role names (e.g. 'Admin,User')
-NEW_WEB_USER_ROLES = 'User'
-NEW_EMAIL_USER_ROLES = 'User'
+# Additional text to include in the "name" part of the From: address used
+# in nosy messages. If the sending user is "Foo Bar", the From: line is
+# usually:
+#    "Foo Bar" <issue_tracker@tracker.example>
+# the EMAIL_FROM_TAG goes inside the "Foo Bar" quotes like so:
+#    "Foo Bar EMAIL_FROM_TAG" <issue_tracker@tracker.example>
+EMAIL_FROM_TAG = ""
 
 # Send nosy messages to the author of the message
 MESSAGES_TO_AUTHOR = 'no'           # either 'yes' or 'no'
@@ -89,4 +89,12 @@
 MAIL_DEFAULT_CLASS = 'issue'   # use "issue" class by default
 #MAIL_DEFAULT_CLASS = ''        # disable (or just comment the var out)
 
+# 
+# SECURITY DEFINITIONS
+#
+# define the Roles that a user gets when they register with the tracker
+# these are a comma-separated string of role names (e.g. 'Admin,User')
+NEW_WEB_USER_ROLES = 'User'
+NEW_EMAIL_USER_ROLES = 'User'
+
 # vim: set filetype=python ts=4 sw=4 et si
--- a/roundup/templates/minimal/config.py	Sun Jan 12 00:03:11 2003 +0000
+++ b/roundup/templates/minimal/config.py	Sun Jan 12 00:41:27 2003 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: config.py,v 1.4 2002-12-13 22:20:10 richard Exp $
+# $Id: config.py,v 1.5 2003-01-12 00:41:27 richard Exp $
 
 import os
 
@@ -49,6 +49,13 @@
 # The email address that roundup will complain to if it runs into trouble
 ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN
 
+# Additional text to include in the "name" part of the From: address used
+# in nosy messages. If the sending user is "Foo Bar", the From: line is
+# usually: "Foo Bar" <issue_tracker@tracker.example>
+# the EMAIL_FROM_TAG goes inside the "Foo Bar" quotes like so:
+#    "Foo Bar EMAIL_FROM_TAG" <issue_tracker@tracker.example>
+EMAIL_FROM_TAG = ""
+
 # 
 # SECURITY DEFINITIONS
 #

Roundup Issue Tracker: http://roundup-tracker.org/