Repository: ietf-tools/datatracker

Issue:
"Email authors" button provides invalid email for https://datatracker.ietf.org/doc/html/rfc4035
### Describe the issue

The "Email authors" gives the email address "rfc4035@ietf.org" which is not found. The automated email response is:

> Address not found
> Your message wasn't delivered to rfc4035@ietf.org because the address couldn't be found, or is unable to receive mail.
> The response from the remote server was:
> 550 5.1.1 <rfc4035@ietf.org>: Recipient address rejected: User unknown in virtual alias table 

Would it be possible to fix the email address in order to communicate with the authors? Thank you!

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:
See also #6214 
Paul - short term fix that won't close this issue, but will at least return us to the datatracker's previous less-bad-than links rathar than links that cannot work behavior.

At the place where this link is emitted, look to see if the rfc came_from_draft and if so, use the draft alias, but _only_ if the generate-draft-aliases script would have emitted the alias. If the rfc didn't come from a draft or the draft wouldn't have a working alias, emit nothing.

We will come back to this later and make rfcnnnn@ aliases, but I want to wait until the new mail processing system is in place first (we will be maintaining the aliases very differently when that happens).

Resolving patch:
diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py
--- a/ietf/doc/views_doc.py
+++ b/ietf/doc/views_doc.py
@@ -324,6 +324,9 @@ def document_main(request, name, rev=None, document_html=False):
                 submission = group.acronym
             submission = '<a href="%s">%s</a>' % (group.about_url(), submission)
 
+        draft = doc.came_from_draft()
+        mailto_name = draft.name if draft else None
+
         return render(request, "doc/document_rfc.html" if document_html is False else "doc/document_html.html",
                                   dict(doc=doc,
                                        document_html=document_html,
@@ -356,7 +359,8 @@ def document_main(request, name, rev=None, document_html=False):
                                        iana_experts_comment=iana_experts_comment,
                                        presentations=presentations,
                                        diff_revisions=diff_revisions,
-                                       submission=submission
+                                       submission=submission,
+                                       mailto_name=mailto_name,
                                        ))
 
     elif doc.type_id == "draft":


Test patch:
diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py
--- a/ietf/doc/tests.py
+++ b/ietf/doc/tests.py
@@ -1,4 +1,4 @@
-# Copyright The IETF Trust 2012-2023, All Rights Reserved
+# Copyright The IETF Trust 2012-2024, All Rights Reserved
 # -*- coding: utf-8 -*-
 
 
@@ -1513,6 +1513,25 @@ def test_draft_group_link(self):
             self.assertEqual(r.status_code, 200)
             self.assert_correct_non_wg_group_link(r, group)
 
+    def test_document_email_authors_button(self):
+        # rfc not from draft
+        rfc = WgRfcFactory()
+        DocEventFactory.create(doc=rfc, type='published_rfc')
+        url = urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=rfc.name))
+        r = self.client.get(url)
+        self.assertEqual(r.status_code, 200)
+        q = PyQuery(r.content)
+        self.assertEqual(len(q('a:contains("Email authors")')), 0, 'Did not expect "Email authors" button')
+
+        # rfc from draft
+        draft = WgDraftFactory(group=rfc.group)
+        draft.relateddocument_set.create(relationship_id="became_rfc", target=rfc)
+        draft.set_state(State.objects.get(used=True, type="draft", slug="rfc"))
+        r = self.client.get(url)
+        self.assertEqual(r.status_code, 200)
+        q = PyQuery(r.content)
+        self.assertEqual(len(q('a:contains("Email authors")')), 1, 'Expected "Email authors" button')
+
     def test_document_primary_and_history_views(self):
         IndividualDraftFactory(name='draft-imaginary-independent-submission')
         ConflictReviewFactory(name='conflict-review-imaginary-irtf-submission')