The 'bcc' argument has no effect
The 'bcc' field appears to be ignored -- the specified recipients are not sent anything. The message is delivered to recipients in the 'to' field. I'm seeing this behavior on version 0.5.0.
Repro case:
import sendgrid
send_client = sendgrid.SendGridClient(SENDGRID_USERNAME, SENDGRID_APIKEY)
message = sendgrid.Mail()
message.add_to('[email protected]')
message.add_bcc('[email protected]')
message.set_subject('test')
message.set_html('test message')
message.set_from('[email protected]')
send_client.send(message)
When the values dict is compiled in SendGridClient.build_body, the x-smtpapi argument will duplicate the to recipients (they're also sent as to[] args). This duplication appears to cause the server to ignore the bcc[] args, even though they are definitely included in the HTTP request.
I'm able to work around this for my purposes by dropping the x-smtpapi key from the values dict when build_body returns since to is the only thing in it, but I doubt that's the right fix here.
Yeah... we are aware of this :( Currently, I'm thinking that if any message object contains a BCC address, to drop the "to" field in the x-smtpapi on the build message step.
https://github.com/sendgrid/sendgrid-python/commit/20bffd28213c37703d91c6ed0297b7e405a2f3b8
Will be updating pypi soon :)
I'm having the except same problem. The email delivers, but only to the to recipient and not the BCC. Same code snippet as above running sendgrid==1.0.1.
@elbuo8 are you sure this issue is resolved?
@mflaxman this was resolved. But from 1.0.0 we dropped the change given that we want all of our libraries to behave the same way. Shoot me an email [email protected] and I will elaborate on this + work with you for a solution.
@scottmotte
Thanks @elbuo8. We switched to mailgun when we ran into the problem so we're all set now, but glad to know that you guys are available if we ever want to switch back.