[#8244] Warn user if attempting to send messages when messaging is disabled
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 1a083ac..06e4330 100644
--- a/Allura/allura/ext/user_profile/templates/send_message_form.html
+++ b/Allura/allura/ext/user_profile/templates/send_message_form.html
@@ -17,10 +17,19 @@
        under the License.
 -#}
 {% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+
+
 <div class="editbox">
+    {% if  c.user.get_pref('disable_user_messages') %}
+    <div class="grid-19 notice">
+        Note: you currently have user messages disabled; you can send this user a note, but you'll be unable to receive any reply without first
+        <a href="/auth/preferences">changing your settings</a>, or providing your email address in the body of the note.
+    </div>
+    {% endif %}
+
     <div class="grid-19">
         <b>To:</b> <a href="{{user.url()}}">{{user.display_name|default(user.username)}}</a>
-        </div>
+    </div>
     <div class="grid-19">
         <b>From:</b> {{c.user.email_address_header()}}
     </div>
diff --git a/Allura/allura/tests/functional/test_user_profile.py b/Allura/allura/tests/functional/test_user_profile.py
index 2707260..04d6458 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -95,7 +95,9 @@
         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
         assert '<b>From:</b> &#34;Test Admin&#34; &lt;test-admin@users.localhost&gt;' in response
+
         self.app.post('/u/test-user/profile/send_user_message',
                       params={'subject': 'test subject',
                               'message': 'test message',
@@ -168,6 +170,19 @@
         assert 'This user has disabled direct email messages' in self.webflash(
             r)
 
+    @td.with_user_project('test-admin')
+    @td.with_user_project('test-user')
+    def test_user_messages_sender_disabled(self):
+        admin_user = User.by_username('test-admin')
+        admin_user.set_pref('email_address', 'admin@example.com')
+        admin_user.set_pref('disable_user_messages', True)
+
+        test_user = User.by_username('test-user')
+        test_user.set_pref('email_address', 'user@example.com')
+
+        r = self.app.get('/u/test-user/profile/send_message', status=200)
+        assert 'you currently have user messages disabled' in r
+
     @td.with_user_project('test-user')
     def test_profile_sections(self):
         project = Project.query.get(shortname='u/test-user')