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

The 'bcc' argument has no effect

Open jdricklefs opened this issue 12 years ago • 5 comments

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.

jdricklefs avatar Apr 14 '14 21:04 jdricklefs

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.

elbuo8 avatar Apr 14 '14 21:04 elbuo8

https://github.com/sendgrid/sendgrid-python/commit/20bffd28213c37703d91c6ed0297b7e405a2f3b8

Will be updating pypi soon :)

elbuo8 avatar Apr 23 '14 18:04 elbuo8

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 avatar Aug 25 '14 18:08 mflaxman

@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

elbuo8 avatar Aug 27 '14 00:08 elbuo8

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.

mflaxman avatar Aug 27 '14 22:08 mflaxman