Attachment '1.6.3-sendmail-expand-to.patch'

Download

   1 From 1075cbf0535360fb10ad483355f057da16f233bb Mon Sep 17 00:00:00 2001
   2 From: Eygene Ryabinkin <rea@codelabs.ru>
   3 Date: Tue, 26 Feb 2008 18:44:13 +0300
   4 Subject: [PATCH] mail/sendmail.py: new option 'expand_to' for sendmail() routine.
   5 
   6 This option, when set to True, instructs sendmail() to put the
   7 actual recipient list to the To: field of the sent mail messages.
   8 Default behaviour was to put sender's e-mail and it is preserved
   9 for the compatibility.
  10 
  11 The need for this modification is simple: modern spam filters,
  12 mailing lists and mail clients are very unhappy when message has
  13 implicit destination.  For example, Mailman software holds such
  14 messages for moderator approval even if the envelope sender is
  15 whitelisted.
  16 
  17 Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
  18 ---
  19  MoinMoin/PageEditor.py         |    3 ++-
  20  MoinMoin/config/multiconfig.py |    3 ++-
  21  MoinMoin/mail/sendmail.py      |    8 +++++++-
  22  wiki/config/wikiconfig.py      |    5 +++++
  23  4 files changed, 16 insertions(+), 3 deletions(-)
  24 
  25 diff --git a/MoinMoin/PageEditor.py b/MoinMoin/PageEditor.py
  26 index 38704c5..ec7e8a7 100644
  27 --- a/MoinMoin/PageEditor.py
  28 +++ b/MoinMoin/PageEditor.py
  29 @@ -752,7 +752,8 @@ Try a different name.""", formatted=True, percent=True) % (wikiutil.escape(newpa
  30                  'pagename': self.page_name,
  31                  'username': self.uid_override or user.getUserIdentification(request),
  32              },
  33 -            mailBody, mail_from=self.cfg.mail_from)
  34 +            mailBody, mail_from=self.cfg.mail_from,
  35 +            expand_to=self.cfg.mail_expand_to)
  36  
  37  
  38      def _notifySubscribers(self, comment, trivial):
  39 diff --git a/MoinMoin/config/multiconfig.py b/MoinMoin/config/multiconfig.py
  40 index 52fc17f..f0da526 100644
  41 --- a/MoinMoin/config/multiconfig.py
  42 +++ b/MoinMoin/config/multiconfig.py
  43 @@ -367,7 +367,8 @@ Lists: * bullets; 1., a. numbered items.
  44      mail_sendmail = None # "/usr/sbin/sendmail -t -i" to not use SMTP, but sendmail
  45      mail_smarthost = None
  46      mail_from = None # u'Juergen Wiki <noreply@jhwiki.org>'
  47 -
  48 +    mail_expand_to = False # set to True if you want all recipients to be listed in To: field
  49 + 
  50      mail_import_subpage_template = u"$from-$date-$subject" # used for mail import
  51      mail_import_pagename_search = ['subject', 'to', ] # where to look for target pagename (and in which order)
  52      mail_import_pagename_envelope = u"%s" # use u"+ %s/" to add "+ " and "/" automatically
  53 diff --git a/MoinMoin/mail/sendmail.py b/MoinMoin/mail/sendmail.py
  54 index e13d32a..d4a37cf 100644
  55 --- a/MoinMoin/mail/sendmail.py
  56 +++ b/MoinMoin/mail/sendmail.py
  57 @@ -49,6 +49,8 @@ def sendmail(request, to, subject, text, **kw):
  58      @param text: email body text (unicode)
  59      @keyword mail_from: override default mail_from
  60      @type mail_from: unicode
  61 +    @keyword expand_to: specify all recipients in the 'To' field
  62 +    @type expand_to: bool
  63      @rtype: tuple
  64      @return: (is_ok, Description of error or OK message)
  65      """
  66 @@ -60,6 +62,7 @@ def sendmail(request, to, subject, text, **kw):
  67      _ = request.getText
  68      cfg = request.cfg
  69      mail_from = kw.get('mail_from', '') or cfg.mail_from
  70 +    expand_to = kw.get('expand_to', False)
  71      subject = subject.encode(config.charset)
  72  
  73      # Create a text/plain body using CRLF (see RFC2822)
  74 @@ -87,7 +90,10 @@ def sendmail(request, to, subject, text, **kw):
  75      # use the same mail_from, e.g. u"Jürgen Wiki <noreply@mywiki.org>"
  76      address = encodeAddress(mail_from, charset)
  77      msg['From'] = address
  78 -    msg['To'] = address
  79 +    if (expand_to == False):
  80 +        msg['To'] = address
  81 +    else:
  82 +        msg['To'] = ", ".join(encodeAddress(i, charset) for i in to)
  83      msg['Date'] = formatdate()
  84      msg['Message-ID'] = make_msgid()
  85      msg['Subject'] = Header(subject, charset)
  86 diff --git a/wiki/config/wikiconfig.py b/wiki/config/wikiconfig.py
  87 index cd47441..15c5cd8 100644
  88 --- a/wiki/config/wikiconfig.py
  89 +++ b/wiki/config/wikiconfig.py
  90 @@ -118,6 +118,11 @@ class Config(DefaultConfig):
  91  
  92      # "user pwd" if you need to use SMTP AUTH
  93      #mail_login = ""
  94 + 
  95 +    # Specify all message recipients in the To: field?  It is useful
  96 +    # if destination mail reader wants explicit message recipient(s).
  97 +    # Default is to use 'mail_from' as a To: field contents.
  98 +    #mail_expand_to = False
  99  
 100  
 101      # User interface ----------------------------------------------------
 102 -- 
 103 1.5.5.3

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2008-06-20 15:27:45, 4.3 KB) [[attachment:1.6.3-sendmail-expand-to.patch]]
  • [get | view] (2008-09-15 20:12:23, 7.3 KB) [[attachment:1.7.2-sendmail-expand-to.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.