incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#6694] push To: header selection up into sendsimplemail
Date Fri, 08 Nov 2013 20:31:07 GMT
Updated Branches:
  refs/heads/master f09d0b649 -> 35eeee58a


[#6694] push To: header selection up into sendsimplemail


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/35eeee58
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/35eeee58
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/35eeee58

Branch: refs/heads/master
Commit: 35eeee58a77133f49d0170bd4ec7dcd92216a16d
Parents: f09d0b6
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Fri Nov 8 20:08:05 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Nov 8 20:08:05 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/mail_util.py    | 15 +++++++--------
 Allura/allura/tasks/mail_tasks.py |  2 +-
 Allura/allura/tests/test_tasks.py |  6 ++++--
 3 files changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/35eeee58/Allura/allura/lib/mail_util.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/mail_util.py b/Allura/allura/lib/mail_util.py
index e6b2b31..ef0cc71 100644
--- a/Allura/allura/lib/mail_util.py
+++ b/Allura/allura/lib/mail_util.py
@@ -202,16 +202,15 @@ class SMTPClient(object):
         self._client = None
 
     def sendmail(self, addrs, fromaddr, reply_to, subject, message_id, in_reply_to, message,
-                 sender=None, references=None, cc=None):
-        if not addrs: return
-        # We send one message with multiple envelope recipients, so use a generic To: addr
-        # It might be nice to refactor to send one message per recipient, and use the actual
To: addr
-        if len(addrs) == 1:
-            message['To'] = AddrHeader(h.really_unicode(addrs[0]))
+                 sender=None, references=None, cc=None, to=None):
+        if not addrs:
+            return
+        if to:
+            message['To'] = AddrHeader(h.really_unicode(to))
         else:
-            message['To'] = Header(reply_to)
+            message['To'] = AddrHeader(reply_to)
         message['From'] = AddrHeader(fromaddr)
-        message['Reply-To'] = Header(reply_to)
+        message['Reply-To'] = AddrHeader(reply_to)
         message['Subject'] = Header(subject)
         message['Message-ID'] = Header('<' + message_id + u'>')
         if sender:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/35eeee58/Allura/allura/tasks/mail_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py
index 8151d34..0b87024 100644
--- a/Allura/allura/tasks/mail_tasks.py
+++ b/Allura/allura/tasks/mail_tasks.py
@@ -167,4 +167,4 @@ def sendsimplemail(
     multi_msg = mail_util.make_multipart_message(plain_msg, html_msg)
     smtp_client.sendmail(
         [toaddr], fromaddr, reply_to, subject, message_id,
-        in_reply_to, multi_msg, sender=sender, references=references, cc=cc)
+        in_reply_to, multi_msg, sender=sender, references=references, cc=cc, to=toaddr)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/35eeee58/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 9015f66..23aab99 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -278,7 +278,7 @@ class TestMailTasks(unittest.TestCase):
             body = body.split('\n')
             assert_in('From: noreply@in.sf.net', body)
 
-    def test_email_sender_header(self):
+    def test_email_sender_to_headers(self):
         c.user = M.User.by_username('test-admin')
         with mock.patch.object(mail_tasks.smtp_client, '_client') as _client:
             mail_tasks.sendsimplemail(
@@ -294,13 +294,14 @@ class TestMailTasks(unittest.TestCase):
             body = body.split('\n')
             assert_in('From: "Test Admin" <test-admin@users.localhost>', body)
             assert_in('Sender: tickets@test.p.sf.net', body)
+            assert_in('To: test@mail.com', body)
 
             _client.reset_mock()
             mail_tasks.sendmail(
                 fromaddr=str(c.user._id),
                 destinations=[ str(c.user._id) ],
                 text=u'This is a test',
-                reply_to=u'noreply@sf.net',
+                reply_to=u'123@tickets.test.p.sf.net',
                 subject=u'Test subject',
                 sender=u'tickets@test.p.sf.net',
                 message_id=h.gen_message_id())
@@ -309,6 +310,7 @@ class TestMailTasks(unittest.TestCase):
             body = body.split('\n')
             assert_in('From: "Test Admin" <test-admin@users.localhost>', body)
             assert_in('Sender: tickets@test.p.sf.net', body)
+            assert_in('To: 123@tickets.test.p.sf.net', body)
 
     def test_email_references_header(self):
         c.user = M.User.by_username('test-admin')


Mime
View raw message