I assume gmail has a separate SMTP session for each BCC recipient. If all that was between your two comments was the dosend(fromAddr, toAddr, content, to, cc, bcc=None) function dosend(fromAddr, toAddr, content, to, cc, bcc=None) , you could do something like this:
dosend(fromAddr, to+cc, content, to, cc) for t in bcc: dosend(fromAddr, t, content, to, cc, t)
This will send it once to the to and cc addresses, and then send them again to each bcc address individually with the corresponding control panel header. To clarify what dosend is: the fromAddr and toAddr refer to the envelope (the first and second server.sendmail arguments). The arguments to , cc and (optionally) bcc for headers in msg . (Your code does not add Bcc, you need to add this if the optional bcc argument is provided.)
(Edit: I deleted my comments about the possibility of using X-Bcc. I just tried it and it works as described above. I also corrected and refined the description of dosend .)
source share