sendgrid-django icon indicating copy to clipboard operation
sendgrid-django copied to clipboard

EmailMultiAlternatives bcc not working

Open sandeepsayone opened this issue 7 years ago • 5 comments

Giving bcc attribute is giving error

mail = EmailMultiAlternatives(subject="Your Subject", body="This is a simple text email body.", from_email="Yamil Asusta <[email protected]>", to=["[email protected]"], bcc=["[email protected]"])
mail.send()
python_http_client/client.py", line 161, in _make_request
    raise exc
BadRequestsError

sandeepsayone avatar Jul 20 '17 09:07 sandeepsayone

I'm actually getting the same error when passing in additional headers to the EmailMultiAlternatives constructor like so: headers={"Reply-To": "[email protected]"}.

I wish I could get more debugging information from the exception itself but it looks it's being raised incorrectly in python_http_client, (line 161 should just be raise to preserve the stack trace).

I'm going to dig into this more to see if I can discover what's going on

sklarsa avatar Jul 20 '17 22:07 sklarsa

I actually ended up creating a new repo (https://github.com/sklarsa/django-sendgrid-v4) to support the sendgrid-python v4.0+ library. It should be compatible with both the EmailMessage and EmailMultiAlternatives django classes, and I'm currently writing out the test suite to guarantee that.

Unfortunately, it looks like this library isn't being maintained on a regular basis, seeing as how PR #58 is accepted(yet still open), and @pcraciunoiu has been left hanging on PR #55, which is a pretty critical PR that deals with breaking changes.

I don't like the idea of creating a new library for basically the same thing, but I am in need of a working sendgrid/django backend for my app. I'd like to hit other unaddressed issues from this repo as well (such as successfully sending emails with embedded images). I'd be happy to accept any help (including Issues and PRs), and am also very open to working with sendgrid and/or the maintainer of this repo to keep this functionality alive.

sklarsa avatar Jul 24 '17 19:07 sklarsa

b'{"errors":[{"message":"Each email address in the personalization block should be unique between to, cc, and bcc. We found the first duplicate instance of [[email protected]] in the personalizations.0.bcc field.","field":"personalizations.0","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.recipient-errors"}]}'

andriisoldatenko avatar Aug 18 '17 23:08 andriisoldatenko

@sandeepsayone please take a look.

andriisoldatenko avatar Aug 18 '17 23:08 andriisoldatenko

@andriisoldatenko thanks. Issues seems to be with to and bcc. I tried with unique emails in to and bcc and it worked. But not working when the to list is empty. I wanted to send emails to many email addresses without each of them knowing who else got the message (bcc) and don't want to give to email address.

sandeepsayone avatar Aug 29 '17 12:08 sandeepsayone