Esempio n. 1
0
 def email_object(email, workaround_name_quote_bug=False):
     """Converts EmailAddress to SendGrid API {email, name} dict"""
     obj = {"email": email.addr_spec}
     if email.display_name:
         # Work around SendGrid API bug: v3 fails to properly quote display-names
         # containing commas or semicolons in personalizations (but not in from_email
         # or reply_to). See https://github.com/sendgrid/sendgrid-python/issues/291.
         # We can work around the problem by quoting the name for SendGrid.
         if workaround_name_quote_bug:
             obj["name"] = '"%s"' % rfc822_quote(email.display_name)
         else:
             obj["name"] = email.display_name
     return obj
Esempio n. 2
0
 def email_object(email, workaround_name_quote_bug=False):
     """Converts ParsedEmail to SendGrid API {email, name} dict"""
     obj = {"email": email.email}
     if email.name:
         # Work around SendGrid API bug: v3 fails to properly quote display-names
         # containing commas or semicolons in personalizations (but not in from_email
         # or reply_to). See https://github.com/sendgrid/sendgrid-python/issues/291.
         # We can work around the problem by quoting the name for SendGrid.
         if workaround_name_quote_bug:
             obj["name"] = '"%s"' % rfc822_quote(email.name)
         else:
             obj["name"] = email.name
     return obj