You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sendgrid.helpers.mail.mail.Mail.from_EmailMessage raises an error from within the sendgrid library.
For some context:
I have code which sends composes and sends emails using python's email package.
I wish to use sendgrid to handle sending the emails as my SMTP proxy service in lieu of AWS SES or some other similar service.
AWS SES offers a send_raw_email method which accepts the result of invoking email.message.EmailMessage.as_bytes() and as such is compatible with my existing code which composes these emails.
I looked at the sendgrid library and this from_EmailMessage classmethod appears to provide a similar bridge from python's native email to provider specific API parameter.
However as documented in this issue it appears that this classmethod is not functional in the latest version of your library.
As a side note: now that this error lead me to look at the implementation of this classmethod it does appear to be too simplistic to account for the complexity of a generic email object. In particular this line would likely raise error if the content were not representable as a string (i.e. the Multipart Content-Type.)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/conda/lib/python3.7/site-packages/sendgrid/helpers/mail/mail.py", line 1000, in from_EmailMessage
to_emails=Email(message.get('To')),
File "/opt/conda/lib/python3.7/site-packages/sendgrid/helpers/mail/mail.py", line 72, in __init__
self.add_to(to_emails, global_substitutions, is_multiple)
File "/opt/conda/lib/python3.7/site-packages/sendgrid/helpers/mail/mail.py", line 276, in add_to
self._set_emails(to_email, global_substitutions, is_multiple, p)
File "/opt/conda/lib/python3.7/site-packages/sendgrid/helpers/mail/mail.py", line 180, in _set_emails
personalization.add_email(emails)
File "/opt/conda/lib/python3.7/site-packages/sendgrid/helpers/mail/personalization.py", line 29, in add_email
raise ValueError('Please use a To, Cc or Bcc object.')
ValueError: Please use a To, Cc or Bcc object.
Technical details:
sendgrid-python version: 6.6.0
python version: 3.7.7
The text was updated successfully, but these errors were encountered:
@kaya-zekioglu This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.
Issue Summary
sendgrid.helpers.mail.mail.Mail.from_EmailMessage
raises an error from within the sendgrid library.For some context:
email
package.send_raw_email
method which accepts the result of invokingemail.message.EmailMessage.as_bytes()
and as such is compatible with my existing code which composes these emails.from_EmailMessage
classmethod appears to provide a similar bridge from python's nativeemail
to provider specific API parameter.Steps to Reproduce
email.message.EmailMessage
(https://docs.python.org/3/library/email.examples.html)sendgrid.helpers.mail.mail.Mail
using thefrom_EmailMessage
classmethodCode Snippet
Exception/Log
Technical details:
The text was updated successfully, but these errors were encountered: