sklarsa / django-sendgrid-v5

An implementation of Django's EmailBackend compatible with sendgrid-python v5+
MIT License
323 stars 54 forks source link

EmailMessage with bcc or cc throwing python_http_client.exceptions.BadRequestsError: HTTP Error 400: Bad Request #89

Closed ranjithsinghu closed 3 years ago

ranjithsinghu commented 3 years ago

With 'to' address it is completely working fine, but with bcc or cc it is throwing error.

msg = EmailMessage(from_email=settings.DEFAULT_FROM_EMAIL, bcc=[user_email])
msg.send()

Failed to send email HTTP Error 400: Bad Request
Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/django/core/mail/message.py", line 284, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/local/lib/python3.8/dist-packages/sendgrid_backend/mail.py", line 129, in send_messages
    resp = self.sg.client.mail.send.post(request_body=data)
  File "/usr/local/lib/python3.8/dist-packages/python_http_client/client.py", line 277, in http_request
    self._make_request(opener, request, timeout=timeout)
  File "/usr/local/lib/python3.8/dist-packages/python_http_client/client.py", line 184, in _make_request
    raise exc
python_http_client.exceptions.BadRequestsError: HTTP Error 400: Bad Request
sklarsa commented 3 years ago

I believe you need at least one email in the to field: https://stackoverflow.com/questions/36715767/sendgrid-not-send-messages-with-only-bcc-addresses