Repository: sklarsa/django-sendgrid-v5

Issue:
Add the ability to reply_to_list for Sendgrid
Since [this](https://github.com/sendgrid/sendgrid-oai/blob/main/CHANGELOG.md#2021-09-22-version-180) version, SendGrid has incorporated the ability to reply to a list of emails. It would be beneficial to integrate this capability into this library without any workarounds.

Discussion:

Patch:
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 3c341bc..56e4923 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -10,5 +10,4 @@ pytest==6.2.5
 pytest-cov==3.0.0
 tox==3.8.5
 twine==3.3.0
-typed-ast==1.5.1
 wheel
diff --git a/sendgrid_backend/mail.py b/sendgrid_backend/mail.py
index dd63787..6e6afb7 100644
--- a/sendgrid_backend/mail.py
+++ b/sendgrid_backend/mail.py
@@ -471,6 +471,13 @@ class SendgridBackend(BaseEmailBackend):
                 )
             )
 
+        if hasattr(msg, "reply_to_list") and SENDGRID_6:
+            from sendgrid.helpers.mail import ReplyTo
+
+            mail.reply_to_list = [
+                ReplyTo(*self._parse_email_address(e)) for e in msg.reply_to_list
+            ]
+
         if hasattr(msg, "categories"):
             for cat in msg.categories:
                 mail.add_category(Category(cat))


Test patch:
diff --git a/test/test_mail.py b/test/test_mail.py
index 55ede5e..bb7862a 100644
--- a/test/test_mail.py
+++ b/test/test_mail.py
@@ -727,3 +727,28 @@ class TestMailGeneration(SimpleTestCase):
         assert not tracking_settings["click_tracking"]["enable"]
         assert "ganalytics" in tracking_settings
         assert tracking_settings["ganalytics"]["utm_source"] == "my-source"
+
+    def test_reply_to_list(self):
+        msg = EmailMessage(
+            subject="Hello, World!",
+            body="Hello, World!",
+            from_email="Sam Smith <sam.smith@example.com>",
+            to=["John Doe <john.doe@example.com>", "jane.doe@example.com"],
+            cc=["Stephanie Smith <stephanie.smith@example.com>"],
+            bcc=["Sarah Smith <sarah.smith@example.com>"],
+        )
+
+        msg.reply_to_list = ["John Doe <john.doe@example.com>", "jane.doe@example.com"]
+
+        mail = self.backend._build_sg_mail(msg)
+
+        reply_to_list = mail.get("reply_to_list")
+        if SENDGRID_5:
+            assert not reply_to_list
+        else:
+            assert reply_to_list
+            assert len(reply_to_list) == 2
+            assert reply_to_list[0].get("email") == "john.doe@example.com"
+            assert reply_to_list[0].get("name") == "John Doe"
+            assert reply_to_list[1].get("email") == "jane.doe@example.com"
+            assert not reply_to_list[1].get("name")