You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/11/15 16:42:29 UTC
[04/50] git commit: [#6694] push To: header selection up into
sendsimplemail
[#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/cj/6777
Commit: 35eeee58a77133f49d0170bd4ec7dcd92216a16d
Parents: f09d0b6
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Nov 8 20:08:05 2013 +0000
Committer: Dave Brondsema <db...@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" <te...@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" <te...@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')