You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by di...@apache.org on 2021/11/17 20:47:04 UTC

[allura] branch master updated (5208f9a -> 3b1ae04)

This is an automated email from the ASF dual-hosted git repository.

dill0wn pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git.


    from 5208f9a  Have a field to track user registration date, not just rely on _id
     new 5cbda17  Added checkbox option that sends message replies to users active email address
     new 314dc8f  message replies to email address is persisted in user preferences, fixed wrong sender email address and reverted 'From' value changes
     new 6b40824  removed email address from FROM: field in form and fixed TestMailTasks
     new 3b1ae04  reverted FROM: field changes and set message_reply_real_address to false if checkbox is unchecked

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../user_profile/templates/send_message_form.html  |  5 +++-
 Allura/allura/ext/user_profile/user_main.py        | 13 +++++++--
 Allura/allura/lib/widgets/user_profile.py          |  1 +
 Allura/allura/model/auth.py                        |  9 ++++--
 .../allura/tests/functional/test_user_profile.py   | 32 +++++++++++++++++++++-
 Allura/allura/tests/test_tasks.py                  |  2 +-
 6 files changed, 54 insertions(+), 8 deletions(-)

[allura] 03/04: removed email address from FROM: field in form and fixed TestMailTasks

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dill0wn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 6b408245d4c57a84acf121097c8438fa713c624a
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Fri Nov 12 13:15:51 2021 -0700

    removed email address from FROM: field in form and fixed TestMailTasks
---
 Allura/allura/model/auth.py                         |  1 -
 Allura/allura/tasks/mail_tasks.py                   |  3 ++-
 Allura/allura/tests/functional/test_user_profile.py |  4 ++--
 Allura/allura/tests/test_tasks.py                   | 14 +++++++-------
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index c656065..1aa71ea 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -819,7 +819,6 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         h = header.Header()
         h.append('"%s"%s' % (self.get_pref('display_name'),
                              ' ' if six.PY2 else ''))  # py2 needs explicit space for unicode/text_type cast of Header
-        h.append('<%s>' % self.get_pref('email_address'))
         return h
 
     def update_notifications(self):
diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py
index c6da880..0df7cc0 100644
--- a/Allura/allura/tasks/mail_tasks.py
+++ b/Allura/allura/tasks/mail_tasks.py
@@ -176,7 +176,8 @@ def sendmail(fromaddr, destinations, text, reply_to, subject,
             except Exception:
                 log.exception('Error looking up user with ID: %r' % addr)
                 continue
-            addr = user.email_address_header()
+            # retrieve active email address
+            addr = user.preferences.email_address
             if not addr and user.email_addresses:
                 addr = user.email_addresses[0]
                 log.warning(
diff --git a/Allura/allura/tests/functional/test_user_profile.py b/Allura/allura/tests/functional/test_user_profile.py
index 7296de8..0db7d57 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -115,7 +115,7 @@ class TestUserProfile(TestController):
         response = self.app.get(
             '/u/test-user/profile/send_message', status=200)
         assert 'you currently have user messages disabled' not in response
-        response.mustcontain('<b>From:</b> &#34;Test Admin&#34; &lt;test-admin@users.localhost&gt;')
+        response.mustcontain('<b>From:</b> &#34;Test Admin&#34;')
 
         self.app.post('/u/test-user/profile/send_user_message',
                       params={'subject': 'test subject',
@@ -163,7 +163,7 @@ class TestUserProfile(TestController):
         response = self.app.get(
             '/u/test-user/profile/send_message', status=200)
         assert 'you currently have user messages disabled' not in response
-        response.mustcontain('<b>From:</b> &#34;Test Admin&#34; &lt;test-admin@users.localhost&gt;')
+        response.mustcontain('<b>From:</b> &#34;Test Admin&#34;')
         self.app.post('/u/test-user/profile/send_user_message',
                       params={'subject': 'test subject',
                               'message': 'test message',
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index c2663b9..ec664e9 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -271,7 +271,7 @@ class TestMailTasks(unittest.TestCase):
 
             assert_equal(rcpts, [c.user.get_pref('email_address')])
             assert_in('Reply-To: %s' % g.noreply, body)
-            assert_in('From: "Test Admin" <te...@users.localhost>', body)
+            assert_in('From: "Test Admin"', body)
             assert_in('Subject: Test subject', body)
             # plain
             assert_in('This is a test', body)
@@ -355,7 +355,7 @@ class TestMailTasks(unittest.TestCase):
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
             body = body.split('\n')
-            assert_in('From: "Test Admin" <te...@users.localhost>', body)
+            assert_in('From: "Test Admin"', body)
 
             c.user.disabled = True
             ThreadLocalORMSession.flush_all()
@@ -385,7 +385,7 @@ class TestMailTasks(unittest.TestCase):
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
             body = body.split('\n')
-            assert_in('From: "Test Admin" <te...@users.localhost>', body)
+            assert_in('From: "Test Admin"', body)
             assert_in('Sender: tickets@test.p.domain.net', body)
             assert_in('To: test@mail.com', body)
 
@@ -401,7 +401,7 @@ class TestMailTasks(unittest.TestCase):
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
             body = body.split('\n')
-            assert_in('From: "Test Admin" <te...@users.localhost>', body)
+            assert_in('From: "Test Admin"', body)
             assert_in('Sender: tickets@test.p.domain.net', body)
             assert_in('To: 123@tickets.test.p.domain.net', body)
 
@@ -419,7 +419,7 @@ class TestMailTasks(unittest.TestCase):
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
             body = body.split('\n')
-            assert_in('From: "Test Admin" <te...@users.localhost>', body)
+            assert_in('From: "Test Admin"', body)
             assert_in('References: <a> <b> <c>', body)
 
             _client.reset_mock()
@@ -434,7 +434,7 @@ class TestMailTasks(unittest.TestCase):
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
             body = body.split('\n')
-            assert_in('From: "Test Admin" <te...@users.localhost>', body)
+            assert_in('From: "Test Admin"', body)
             assert_in('References: <ref>', body)
 
     def test_cc(self):
@@ -465,7 +465,7 @@ class TestMailTasks(unittest.TestCase):
                 message_id=h.gen_message_id())
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
-            assert_in('From: "Test Admin" <te...@users.localhost>', body)
+            assert_in('From: "Test Admin"', body)
 
     def test_send_email_long_lines_use_quoted_printable(self):
         with mock.patch.object(mail_tasks.smtp_client, '_client') as _client:

[allura] 01/04: Added checkbox option that sends message replies to users active email address

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dill0wn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 5cbda1724bd303ee599f58d70028b162debb0df6
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Mon Nov 1 07:58:31 2021 -0600

    Added checkbox option that sends message replies to users active email address
---
 .../user_profile/templates/send_message_form.html  |  3 +++
 Allura/allura/ext/user_profile/user_main.py        |  4 +--
 Allura/allura/lib/widgets/user_profile.py          |  1 +
 Allura/allura/model/auth.py                        |  9 ++++---
 .../allura/tests/functional/test_user_profile.py   | 31 +++++++++++++++++++++-
 5 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/Allura/allura/ext/user_profile/templates/send_message_form.html b/Allura/allura/ext/user_profile/templates/send_message_form.html
index 279572f..df31796 100644
--- a/Allura/allura/ext/user_profile/templates/send_message_form.html
+++ b/Allura/allura/ext/user_profile/templates/send_message_form.html
@@ -47,6 +47,9 @@
         <div class="grid-19">
             {{widget.display_field(widget.fields.cc)}}
         </div>
+          <div class="grid-19">
+            {{widget.display_field(widget.fields.reply_to_real_address)}}
+        </div>
         <div class="grid-19">&nbsp;</div>
         <div class="grid-12">
             {{buttons[0].display()}}
diff --git a/Allura/allura/ext/user_profile/user_main.py b/Allura/allura/ext/user_profile/user_main.py
index f63bffe..2240e0f 100644
--- a/Allura/allura/ext/user_profile/user_main.py
+++ b/Allura/allura/ext/user_profile/user_main.py
@@ -195,7 +195,7 @@ class UserProfileController(BaseController, FeedController):
     @expose()
     @validate(dict(subject=validators.NotEmpty,
                    message=validators.NotEmpty))
-    def send_user_message(self, subject='', message='', cc=None):
+    def send_user_message(self, subject='', message='', cc=None, reply_to_real_address=None):
         """Handle POST for sending a message to another user.
 
         """
@@ -205,7 +205,7 @@ class UserProfileController(BaseController, FeedController):
             cc = c.user.get_pref('email_address')
         if c.user.can_send_user_message():
             c.user.send_user_message(
-                c.project.user_project_of, subject, message, cc)
+                c.project.user_project_of, subject, message, cc, reply_to_real_address)
             flash("Message sent.")
         else:
             flash("You can't send more than %i messages per %i seconds" % (
diff --git a/Allura/allura/lib/widgets/user_profile.py b/Allura/allura/lib/widgets/user_profile.py
index e6162b0..0c81356 100644
--- a/Allura/allura/lib/widgets/user_profile.py
+++ b/Allura/allura/lib/widgets/user_profile.py
@@ -63,6 +63,7 @@ class SendMessageForm(ForgeForm):
             label='Message')
 
         cc = ew.Checkbox(label='Send me a copy')
+        reply_to_real_address = ew.Checkbox(label='Include my active email address in the reply field for this message')
 
 
 class SectionsUtil(object):
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 7df4c8a..a69eb78 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -457,7 +457,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
                 timedelta(seconds=g.user_message_time_interval) -
                 datetime.utcnow())
 
-    def send_user_message(self, user, subject, message, cc):
+    def send_user_message(self, user, subject, message, cc, reply_to_real_address):
         """Send a user message (email) to ``user``.
 
         """
@@ -469,10 +469,12 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
             'base_url': config['base_url'],
             'user': c.user,
         }
+        real_address = user.preferences.email_address
+        reply_to = real_address if reply_to_real_address and real_address else self.get_pref('email_address')
         allura.tasks.mail_tasks.sendsimplemail.post(
             toaddr=user.get_pref('email_address'),
             fromaddr=self.get_pref('email_address'),
-            reply_to=self.get_pref('email_address'),
+            reply_to=reply_to,
             message_id=h.gen_message_id(),
             subject=subject,
             text=tmpl.render(tmpl_context),
@@ -812,9 +814,8 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
 
     def email_address_header(self):
         h = header.Header()
-        h.append('"%s"%s' % (self.get_pref('display_name'),
+        h.append('%s %s' % (self.get_pref('display_name'),
                              ' ' if six.PY2 else ''))  # py2 needs explicit space for unicode/text_type cast of Header
-        h.append('<%s>' % self.get_pref('email_address'))
         return h
 
     def update_notifications(self):
diff --git a/Allura/allura/tests/functional/test_user_profile.py b/Allura/allura/tests/functional/test_user_profile.py
index 43e4770..ac538dd 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -115,7 +115,7 @@ class TestUserProfile(TestController):
         response = self.app.get(
             '/u/test-user/profile/send_message', status=200)
         assert 'you currently have user messages disabled' not in response
-        response.mustcontain('<b>From:</b> &#34;Test Admin&#34; &lt;test-admin@users.localhost&gt;')
+        response.mustcontain('<b>From:</b> Test Admin')
 
         self.app.post('/u/test-user/profile/send_user_message',
                       params={'subject': 'test subject',
@@ -149,6 +149,35 @@ class TestUserProfile(TestController):
             '/u/test-user/profile/send_message', status=200)
         assert 'Sorry, messaging is rate-limited' in response
 
+    @td.with_user_project('test-admin')
+    @td.with_user_project('test-user')
+    @mock.patch('allura.tasks.mail_tasks.sendsimplemail')
+    @mock.patch('allura.lib.helpers.gen_message_id')
+    @mock.patch('allura.model.User.can_send_user_message')
+    def test_send_message_with_real_address_reply(self, check, gen_message_id, sendsimplemail):
+        check.return_value = True
+        gen_message_id.return_value = 'id'
+        test_user = User.by_username('test-user')
+        test_user.set_pref('email_address', 'test-user@example.com')
+        response = self.app.get(
+            '/u/test-user/profile/send_message', status=200)
+        assert 'you currently have user messages disabled' not in response
+        response.mustcontain('<b>From:</b> Test Admin')
+        self.app.post('/u/test-user/profile/send_user_message',
+                      params={'subject': 'test subject',
+                              'message': 'test message',
+                              'cc': 'on',
+                              'reply_to_real_address': 'on'})
+        real_address = test_user.preferences.email_address
+        sendsimplemail.post.assert_called_once_with(
+            cc=User.by_username('test-admin').get_pref('email_address'),
+            text='test message\n\n---\n\nThis message was sent to you via the Allura web mail form.  You may reply to this message directly, or send a message to Test Admin at http://localhost/u/test-admin/profile/send_message\n',
+            toaddr=User.by_username('test-user').get_pref('email_address'),
+            fromaddr=User.by_username('test-admin').get_pref('email_address'),
+            reply_to=real_address,
+            message_id='id',
+            subject='test subject')
+
     @td.with_user_project('test-user')
     def test_send_message_for_anonymous(self):
         r = self.app.get('/u/test-user/profile/send_message',

[allura] 02/04: message replies to email address is persisted in user preferences, fixed wrong sender email address and reverted 'From' value changes

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dill0wn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 314dc8f37c1d59c7eb8f23e74e6200815a8b24e9
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Mon Nov 8 15:53:15 2021 -0700

    message replies to email address is persisted in user preferences, fixed wrong sender email address and reverted 'From' value changes
---
 Allura/allura/ext/user_profile/user_main.py         |  7 ++++++-
 Allura/allura/lib/widgets/user_profile.py           |  2 +-
 Allura/allura/model/auth.py                         | 10 +++++++---
 Allura/allura/tests/functional/test_user_profile.py |  9 +++++----
 4 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/Allura/allura/ext/user_profile/user_main.py b/Allura/allura/ext/user_profile/user_main.py
index 2240e0f..b7ca32b 100644
--- a/Allura/allura/ext/user_profile/user_main.py
+++ b/Allura/allura/ext/user_profile/user_main.py
@@ -189,6 +189,8 @@ class UserProfileController(BaseController, FeedController):
         delay = c.user.time_to_next_user_message()
         expire_time = str(delay) if delay else None
         c.form = F.send_message
+        if c.user.get_pref('message_reply_real_address'):
+            c.form.fields.reply_to_real_address.attrs = {'checked': 'checked'}
         return dict(user=c.project.user_project_of, expire_time=expire_time)
 
     @require_post()
@@ -203,9 +205,12 @@ class UserProfileController(BaseController, FeedController):
 
         if cc:
             cc = c.user.get_pref('email_address')
+
         if c.user.can_send_user_message():
+            if reply_to_real_address:
+                c.user.set_pref('message_reply_real_address', True)
             c.user.send_user_message(
-                c.project.user_project_of, subject, message, cc, reply_to_real_address)
+                c.project.user_project_of, subject, message, cc, reply_to_real_address, c.user.preferences.email_address)
             flash("Message sent.")
         else:
             flash("You can't send more than %i messages per %i seconds" % (
diff --git a/Allura/allura/lib/widgets/user_profile.py b/Allura/allura/lib/widgets/user_profile.py
index 0c81356..ee0d652 100644
--- a/Allura/allura/lib/widgets/user_profile.py
+++ b/Allura/allura/lib/widgets/user_profile.py
@@ -63,7 +63,7 @@ class SendMessageForm(ForgeForm):
             label='Message')
 
         cc = ew.Checkbox(label='Send me a copy')
-        reply_to_real_address = ew.Checkbox(label='Include my active email address in the reply field for this message')
+        reply_to_real_address = ew.Checkbox(label='Include my email address in the reply field for this message')
 
 
 class SectionsUtil(object):
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index a69eb78..c656065 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -276,6 +276,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         disable_user_messages=bool,
         mention_notifications=bool,
         multifactor=bool,
+        message_reply_real_address=bool,
     ))
     # Additional top-level fields can/should be accessed with get/set_pref also
     # Not sure why we didn't put them within the 'preferences' dictionary :(
@@ -457,7 +458,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
                 timedelta(seconds=g.user_message_time_interval) -
                 datetime.utcnow())
 
-    def send_user_message(self, user, subject, message, cc, reply_to_real_address):
+    def send_user_message(self, user, subject, message, cc, reply_to_real_address, sender_email_address):
         """Send a user message (email) to ``user``.
 
         """
@@ -470,7 +471,9 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
             'user': c.user,
         }
         real_address = user.preferences.email_address
-        reply_to = real_address if reply_to_real_address and real_address else self.get_pref('email_address')
+        reply_to = self.get_pref('email_address')
+        if reply_to_real_address:
+            reply_to = sender_email_address
         allura.tasks.mail_tasks.sendsimplemail.post(
             toaddr=user.get_pref('email_address'),
             fromaddr=self.get_pref('email_address'),
@@ -814,8 +817,9 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
 
     def email_address_header(self):
         h = header.Header()
-        h.append('%s %s' % (self.get_pref('display_name'),
+        h.append('"%s"%s' % (self.get_pref('display_name'),
                              ' ' if six.PY2 else ''))  # py2 needs explicit space for unicode/text_type cast of Header
+        h.append('<%s>' % self.get_pref('email_address'))
         return h
 
     def update_notifications(self):
diff --git a/Allura/allura/tests/functional/test_user_profile.py b/Allura/allura/tests/functional/test_user_profile.py
index ac538dd..7296de8 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -115,7 +115,7 @@ class TestUserProfile(TestController):
         response = self.app.get(
             '/u/test-user/profile/send_message', status=200)
         assert 'you currently have user messages disabled' not in response
-        response.mustcontain('<b>From:</b> Test Admin')
+        response.mustcontain('<b>From:</b> &#34;Test Admin&#34; &lt;test-admin@users.localhost&gt;')
 
         self.app.post('/u/test-user/profile/send_user_message',
                       params={'subject': 'test subject',
@@ -158,23 +158,24 @@ class TestUserProfile(TestController):
         check.return_value = True
         gen_message_id.return_value = 'id'
         test_user = User.by_username('test-user')
+        test_admin = User.by_username('test-admin')
         test_user.set_pref('email_address', 'test-user@example.com')
         response = self.app.get(
             '/u/test-user/profile/send_message', status=200)
         assert 'you currently have user messages disabled' not in response
-        response.mustcontain('<b>From:</b> Test Admin')
+        response.mustcontain('<b>From:</b> &#34;Test Admin&#34; &lt;test-admin@users.localhost&gt;')
         self.app.post('/u/test-user/profile/send_user_message',
                       params={'subject': 'test subject',
                               'message': 'test message',
                               'cc': 'on',
                               'reply_to_real_address': 'on'})
-        real_address = test_user.preferences.email_address
+        sender_address = test_admin.preferences.email_address
         sendsimplemail.post.assert_called_once_with(
             cc=User.by_username('test-admin').get_pref('email_address'),
             text='test message\n\n---\n\nThis message was sent to you via the Allura web mail form.  You may reply to this message directly, or send a message to Test Admin at http://localhost/u/test-admin/profile/send_message\n',
             toaddr=User.by_username('test-user').get_pref('email_address'),
             fromaddr=User.by_username('test-admin').get_pref('email_address'),
-            reply_to=real_address,
+            reply_to=sender_address,
             message_id='id',
             subject='test subject')
 

[allura] 04/04: reverted FROM: field changes and set message_reply_real_address to false if checkbox is unchecked

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dill0wn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 3b1ae04b80f2f01b3263238999aadd9e64f361af
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Tue Nov 16 15:33:58 2021 -0700

    reverted FROM: field changes and set message_reply_real_address to false if checkbox is unchecked
---
 .../ext/user_profile/templates/send_message_form.html    |  2 +-
 Allura/allura/ext/user_profile/user_main.py              |  4 +++-
 Allura/allura/model/auth.py                              |  1 +
 Allura/allura/tasks/mail_tasks.py                        |  3 +--
 Allura/allura/tests/functional/test_user_profile.py      |  4 ++--
 Allura/allura/tests/test_tasks.py                        | 16 ++++++++--------
 6 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/Allura/allura/ext/user_profile/templates/send_message_form.html b/Allura/allura/ext/user_profile/templates/send_message_form.html
index df31796..26caa8f 100644
--- a/Allura/allura/ext/user_profile/templates/send_message_form.html
+++ b/Allura/allura/ext/user_profile/templates/send_message_form.html
@@ -31,7 +31,7 @@
         <b>To:</b> <a href="{{user.url()}}">{{user.display_name|default(user.username)}}</a>
     </div>
     <div class="grid-19">
-        <b>From:</b> {{c.user.email_address_header()}}
+        <b>From:</b> {{c.user.display_name}}
     </div>
     <div class="grid-19">&nbsp;</div>
     <form method="{{method}}" action="{{action}}">
diff --git a/Allura/allura/ext/user_profile/user_main.py b/Allura/allura/ext/user_profile/user_main.py
index b7ca32b..22b4200 100644
--- a/Allura/allura/ext/user_profile/user_main.py
+++ b/Allura/allura/ext/user_profile/user_main.py
@@ -209,6 +209,8 @@ class UserProfileController(BaseController, FeedController):
         if c.user.can_send_user_message():
             if reply_to_real_address:
                 c.user.set_pref('message_reply_real_address', True)
+            else:
+                c.user.set_pref('message_reply_real_address', False)
             c.user.send_user_message(
                 c.project.user_project_of, subject, message, cc, reply_to_real_address, c.user.preferences.email_address)
             flash("Message sent.")
@@ -217,7 +219,7 @@ class UserProfileController(BaseController, FeedController):
                 g.user_message_max_messages,
                 g.user_message_time_interval), 'error')
         return redirect(c.project.user_project_of.url())
-        
+
     @without_trailing_slash
     @expose('jinja:allura.ext.user_profile:templates/user_card.html')
     def user_card(self):
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 1aa71ea..c656065 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -819,6 +819,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         h = header.Header()
         h.append('"%s"%s' % (self.get_pref('display_name'),
                              ' ' if six.PY2 else ''))  # py2 needs explicit space for unicode/text_type cast of Header
+        h.append('<%s>' % self.get_pref('email_address'))
         return h
 
     def update_notifications(self):
diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py
index 0df7cc0..c6da880 100644
--- a/Allura/allura/tasks/mail_tasks.py
+++ b/Allura/allura/tasks/mail_tasks.py
@@ -176,8 +176,7 @@ def sendmail(fromaddr, destinations, text, reply_to, subject,
             except Exception:
                 log.exception('Error looking up user with ID: %r' % addr)
                 continue
-            # retrieve active email address
-            addr = user.preferences.email_address
+            addr = user.email_address_header()
             if not addr and user.email_addresses:
                 addr = user.email_addresses[0]
                 log.warning(
diff --git a/Allura/allura/tests/functional/test_user_profile.py b/Allura/allura/tests/functional/test_user_profile.py
index 0db7d57..ecaa6f5 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -115,7 +115,7 @@ class TestUserProfile(TestController):
         response = self.app.get(
             '/u/test-user/profile/send_message', status=200)
         assert 'you currently have user messages disabled' not in response
-        response.mustcontain('<b>From:</b> &#34;Test Admin&#34;')
+        response.mustcontain('<b>From:</b> Test Admin')
 
         self.app.post('/u/test-user/profile/send_user_message',
                       params={'subject': 'test subject',
@@ -163,7 +163,7 @@ class TestUserProfile(TestController):
         response = self.app.get(
             '/u/test-user/profile/send_message', status=200)
         assert 'you currently have user messages disabled' not in response
-        response.mustcontain('<b>From:</b> &#34;Test Admin&#34;')
+        response.mustcontain('<b>From:</b> Test Admin')
         self.app.post('/u/test-user/profile/send_user_message',
                       params={'subject': 'test subject',
                               'message': 'test message',
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index ec664e9..7c73399 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -34,7 +34,7 @@ import mock
 from tg import tmpl_context as c, app_globals as g
 
 from datadiff.tools import assert_equal
-from alluratest.tools import assert_in, assert_less
+from nose.tools import assert_in, assert_less
 from ming.orm import FieldProperty, Mapper
 from ming.orm import ThreadLocalORMSession
 from testfixtures import LogCapture
@@ -271,7 +271,7 @@ class TestMailTasks(unittest.TestCase):
 
             assert_equal(rcpts, [c.user.get_pref('email_address')])
             assert_in('Reply-To: %s' % g.noreply, body)
-            assert_in('From: "Test Admin"', body)
+            assert_in('From: "Test Admin" <te...@users.localhost>', body)
             assert_in('Subject: Test subject', body)
             # plain
             assert_in('This is a test', body)
@@ -355,7 +355,7 @@ class TestMailTasks(unittest.TestCase):
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
             body = body.split('\n')
-            assert_in('From: "Test Admin"', body)
+            assert_in('From: "Test Admin" <te...@users.localhost>', body)
 
             c.user.disabled = True
             ThreadLocalORMSession.flush_all()
@@ -385,7 +385,7 @@ class TestMailTasks(unittest.TestCase):
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
             body = body.split('\n')
-            assert_in('From: "Test Admin"', body)
+            assert_in('From: "Test Admin" <te...@users.localhost>', body)
             assert_in('Sender: tickets@test.p.domain.net', body)
             assert_in('To: test@mail.com', body)
 
@@ -401,7 +401,7 @@ class TestMailTasks(unittest.TestCase):
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
             body = body.split('\n')
-            assert_in('From: "Test Admin"', body)
+            assert_in('From: "Test Admin" <te...@users.localhost>', body)
             assert_in('Sender: tickets@test.p.domain.net', body)
             assert_in('To: 123@tickets.test.p.domain.net', body)
 
@@ -419,7 +419,7 @@ class TestMailTasks(unittest.TestCase):
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
             body = body.split('\n')
-            assert_in('From: "Test Admin"', body)
+            assert_in('From: "Test Admin" <te...@users.localhost>', body)
             assert_in('References: <a> <b> <c>', body)
 
             _client.reset_mock()
@@ -434,7 +434,7 @@ class TestMailTasks(unittest.TestCase):
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
             body = body.split('\n')
-            assert_in('From: "Test Admin"', body)
+            assert_in('From: "Test Admin" <te...@users.localhost>', body)
             assert_in('References: <ref>', body)
 
     def test_cc(self):
@@ -465,7 +465,7 @@ class TestMailTasks(unittest.TestCase):
                 message_id=h.gen_message_id())
             assert_equal(_client.sendmail.call_count, 1)
             return_path, rcpts, body = _client.sendmail.call_args[0]
-            assert_in('From: "Test Admin"', body)
+            assert_in('From: "Test Admin" <te...@users.localhost>', body)
 
     def test_send_email_long_lines_use_quoted_printable(self):
         with mock.patch.object(mail_tasks.smtp_client, '_client') as _client: