diff --git a/reviewboard/notifications/email.py b/reviewboard/notifications/email.py
index 8b4c23d924f5cf395d5c03bc9b59a72baa890c48..98e69de673af661ab446b8fabe6ac89f89a8ff80 100644
--- a/reviewboard/notifications/email.py
+++ b/reviewboard/notifications/email.py
@@ -34,6 +34,16 @@ from reviewboard.webapi.models import WebAPIToken
 # A mapping of signals to EmailHooks.
 _hooks = defaultdict(set)
 
+MAX_FILENAME_HEADERS_LENGTH = 8192
+
+#: The number of additional characters each ``X-ReviewBoard-Diff-For`` has.
+#:
+#: We calculate the length the value of each header at runtime. However,
+#: ``X-ReviewBoard-Diff-For: `` is present before the value, and the line
+#: terminates with a ``\r\n``.
+HEADER_ADDITIONAL_CHARACTERS_LENGTH = (len('\r\n') +
+                                       len('X-ReviewBoard-Diff-For: '))
+
 
 def _ensure_unicode(text):
     """Return a unicode object for the given text.
@@ -599,7 +609,27 @@ def send_review_mail(user, review_request, subject, in_reply_to,
             if filediff.is_new or filediff.copied or filediff.moved:
                 modified_files.add(filediff.dest_file)
 
+        # The following code segment deals with the case where the client adds
+        # a significant amount of files with large names. We limit the number
+        # of headers; when more than 8192 characters are reached, we stop
+        # adding filename headers.
+        current_header_length = 0
+
         for filename in modified_files:
+            current_header_length += (HEADER_ADDITIONAL_CHARACTERS_LENGTH +
+                                      len(filename))
+            if current_header_length > MAX_FILENAME_HEADERS_LENGTH:
+
+                logging.warning(
+                    'Unable to store all filenames in '
+                    'X-ReviewBoard-Diff-For header when sending '
+                    'e-mail for review request %s: The header '
+                    'size exceeds the limit of %s. Remaining '
+                    'headers have been removed.',
+                    review_request.display_id,
+                    MAX_FILENAME_HEADERS_LENGTH)
+                break
+
             headers.appendlist('X-ReviewBoard-Diff-For', filename)
 
     subject = subject.strip()
diff --git a/reviewboard/notifications/tests.py b/reviewboard/notifications/tests.py
index 0dfc317864d5366de92f811fb837e54a465b9ee3..f0e83a469b60567c23fc9c521b691b478912424c 100644
--- a/reviewboard/notifications/tests.py
+++ b/reviewboard/notifications/tests.py
@@ -892,6 +892,53 @@ class ReviewRequestEmailTests(EmailTestHelper, DmarcDnsTestsMixin, SpyAgency,
         self.assertTrue(filediff.dest_file in diff_headers)
 
     @add_fixtures(['test_scmtools'])
+    def test_review_request_email_with_added_files_over_header_limit(self):
+        """Testing sending a review request e-mail with added files in the
+        diffset such that the filename headers take up more than 8192
+        characters
+        """
+        self.spy_on(logging.warning)
+        self.maxDiff = None
+
+        repository = self.create_repository(tool_name='Test')
+        review_request = self.create_review_request(repository=repository)
+        diffset = self.create_diffset(review_request=review_request)
+        prefix = 'X' * 99
+
+        for i in range(400):
+            filename = '%s%s' % (prefix, i)
+            # We want every filename to have a length of exactly 100.
+            # However, depending on the value of i, the length may be up to
+            # 102.
+            filename = filename[(len(filename) - 100):]
+            self.assertEqual(len(filename), 100)
+            self.create_filediff(diffset=diffset,
+                                 source_file=filename,
+                                 dest_file=filename,
+                                 source_revision=PRE_CREATION)
+
+        review_request.publish(review_request.submitter)
+
+        self.assertEqual(len(mail.outbox), 1)
+        message = mail.outbox[0]
+
+        self.assertTrue('X-ReviewBoard-Diff-For' in message._headers)
+        diff_headers = message._headers.getlist('X-ReviewBoard-Diff-For')
+        # There are supposed to be 64 headers. Each filename is 100 characters
+        # long. Then, for each header we add 26 characters: the key, a ': ',
+        # and the terminating "\r\n". 8192 / (100 + 26) rounds down to 65.
+        self.assertEqual(len(logging.warning.spy.calls), 1)
+        self.assertEqual(len(diff_headers), 65)
+
+        self.assertEqual(logging.warning.spy.calls[0].args[1], 1)
+        self.assertEqual(logging.warning.spy.calls[0].args[2], 8192)
+        self.assertEqual(logging.warning.spy.calls[0].args[0],
+                         'Unable to store all filenames in '
+                         'X-ReviewBoard-Diff-For header when sending e-mail '
+                         'for review request %s: The header size exceeds the '
+                         'limit of %s. Remaining headers have been removed.')
+
+    @add_fixtures(['test_scmtools'])
     def test_review_request_email_with_deleted_file(self):
         """Testing sending a review request e-mail with deleted files in the
         diffset
