-
Notifications
You must be signed in to change notification settings - Fork 728
Closed
Labels
difficulty: easyfix is easy in difficultyfix is easy in difficultystatus: help wantedrequesting help from the communityrequesting help from the communitytype: community enhancementfeature request not on Twilio's roadmapfeature request not on Twilio's roadmap
Description
Issue Summary
Something I ran into while upgrading to 6.0.2 just now is that when sending a Mail object with a to_emails= parameter that is a list of [[email, name]], a confusing exception is thrown while if it's a list of [(email, name)], it succeeds.
This snippet fails
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
email_list = [["myemail+uno@gmail.com", "Benjamin Uno"],
["myemail+dos@gmail.com", "Benjamin Dos"]]
mail = Mail(subject=subject,
html_content=content,
from_email=("hello@website.com", "Website Team"),
to_emails=email_list,
)
sendgrid_client = SendGridAPIClient('abcd123')
sendgrid_client.send(mail)The exception thrown is ValueError: Please use a To, Cc or Bcc object.
This snippet succeeds
email_list = [("myemail+uno@gmail.com", "Benjamin Uno"),
("myemail+dos@gmail.com", "Benjamin Dos")]
# (( Same code as above ))
Steps to Reproduce
- Run the initial snippet above
Expected
- Option 1: accept a list of lists as well as a list of tuples. This seems doable but there may be ancient backwards incompatibility reasons why it's hard.
- Option 2: fail immediately if you see a list of lists. Otherwise the error "Please use a To, Cc or Bcc object." is pretty confusing and took me a while to figure out why sendgrid was unhappy.
Technical details:
- sendgrid-python Version: 6.0.2
- Python Version: 3.7
Metadata
Metadata
Assignees
Labels
difficulty: easyfix is easy in difficultyfix is easy in difficultystatus: help wantedrequesting help from the communityrequesting help from the communitytype: community enhancementfeature request not on Twilio's roadmapfeature request not on Twilio's roadmap