@@ -235,6 +235,58 @@ def test_send_a_single_email_to_multiple_recipients(self):
235235 }''' )
236236 )
237237
238+ def test_send_a_single_email_with_multiple_reply_to_addresses (self ):
239+ from sendgrid .helpers .mail import (Mail , From , ReplyTo , To , Subject ,
240+ PlainTextContent , HtmlContent )
241+ self .maxDiff = None
242+ message = Mail (
243+ from_email = From (
'[email protected] ' ,
'Example From Name' ),
244+ to_emails = To (
'[email protected] ' ,
'Example To Name' ),
245+ subject = Subject ('Sending with SendGrid is Fun' ),
246+ plain_text_content = PlainTextContent ('and easy to do anywhere, even with Python' ),
247+ html_content = HtmlContent ('<strong>and easy to do anywhere, even with Python</strong>' ))
248+
249+ message .
reply_to_list = [
ReplyTo (
email = '[email protected] ' ),
ReplyTo (
email = '[email protected] ' )]
250+
251+ self .assertEqual (
252+ message .get (),
253+ json .loads (r'''{
254+ "content": [
255+ {
256+ "type": "text/plain",
257+ "value": "and easy to do anywhere, even with Python"
258+ },
259+ {
260+ "type": "text/html",
261+ "value": "<strong>and easy to do anywhere, even with Python</strong>"
262+ }
263+ ],
264+ "from": {
265+ 266+ "name": "Example From Name"
267+ },
268+ "personalizations": [
269+ {
270+ "to": [
271+ {
272+ 273+ "name": "Example To Name"
274+ }
275+ ]
276+ }
277+ ],
278+ "reply_to_list": [
279+ {
280+ 281+ },
282+ {
283+ 284+ }
285+ ],
286+ "subject": "Sending with SendGrid is Fun"
287+ }''' )
288+ )
289+
238290 def test_multiple_emails_to_multiple_recipients (self ):
239291 from sendgrid .helpers .mail import (Mail , From , To , Subject ,
240292 PlainTextContent , HtmlContent ,
@@ -568,6 +620,44 @@ def test_value_error_is_raised_on_to_emails_set_to_list_of_lists(self):
568620 'and easy to do anywhere, even with Python' ),
569621 html_content = HtmlContent (
570622 '<strong>and easy to do anywhere, even with Python</strong>' ))
623+
624+ def test_value_error_is_raised_on_to_emails_set_to_reply_to_list_of_strs (self ):
625+ from sendgrid .helpers .mail import (PlainTextContent , HtmlContent )
626+ self .maxDiff = None
627+ to_emails = [
628+ (
'[email protected] ' ,
'Example To Name 0' ),
629+ (
'[email protected] ' ,
'Example To Name 1' )
630+ ]
631+
632+ mail = Mail (
633+ from_email = From (
'[email protected] ' ,
'Example From Name' ),
634+ to_emails = to_emails ,
635+ subject = Subject ('Sending with SendGrid is Fun' ),
636+ plain_text_content = PlainTextContent (
637+ 'and easy to do anywhere, even with Python' ),
638+ html_content = HtmlContent (
639+ '<strong>and easy to do anywhere, even with Python</strong>' ))
640+ with self .assertRaises (ValueError ):
641+ 642+
643+ def test_value_error_is_raised_on_to_emails_set_to_reply_to_list_of_tuples (self ):
644+ from sendgrid .helpers .mail import (PlainTextContent , HtmlContent )
645+ self .maxDiff = None
646+ to_emails = [
647+ (
'[email protected] ' ,
'Example To Name 0' ),
648+ (
'[email protected] ' ,
'Example To Name 1' )
649+ ]
650+
651+ mail = Mail (
652+ from_email = From (
'[email protected] ' ,
'Example From Name' ),
653+ to_emails = to_emails ,
654+ subject = Subject ('Sending with SendGrid is Fun' ),
655+ plain_text_content = PlainTextContent (
656+ 'and easy to do anywhere, even with Python' ),
657+ html_content = HtmlContent (
658+ '<strong>and easy to do anywhere, even with Python</strong>' ))
659+ with self .assertRaises (ValueError ):
660+ mail .
reply_to_list = [(
'[email protected] ' ,
'Test Name' )]
571661
572662 def test_error_is_not_raised_on_to_emails_set_to_list_of_tuples (self ):
573663 from sendgrid .helpers .mail import (PlainTextContent , HtmlContent )
0 commit comments