python - Bcc Field in SMTP [ showing/not showing ] problem -
i'm trying use python's smtplib send, via gmail, email bcc addresses. use code:
#imports etc... fromaddr = sender@origin.com = [ recpt1@destinationto.com ] cc = [ recpt2@destinationcc.com ] bcc = [ recpt3@destinationbcc.com, recpt4@destinationbcc.com ] server = smtp( "smtp.gmail.com", 587) #starttls, login, etc.. content = "hello, message." msg = "from: %s\r\nto:%s\r\ncc: %s\r\n\r\n%s" % ( from, to, cc, content ) server.sendmail( fromaddr, + cc + bcc, msg ) #server.quit() etc... -> when go respective inboxs same message addresses in [to+cc+bcc], wich right. but
what happen each bcc address got bcc field own address in it, described in here web interface of gmail.
this wish accomplish:
cc , inboxes:
to: recpt1@destinationto.com from: sender@origin.com cc: recpt2@destinationcc.com (...) recpt3 inbox:
to: recpt1@destinationto.com from: sender@origin.com cc: recpt2@destinationcc.com bcc: recpt3@destinationbcc.com (...) recpt4 inbox:
to: recpt1@destinationto.com from: sender@origin.com cc: recpt2@destinationcc.com bcc: recpt4@destinationbcc.com (...) has managed working? i've been looking in smtp rfc documents , i've found nothing, dont understand how gmail can it
my guess gmail separate smtp session each bcc recipient. if between 2 comments function dosend(fromaddr, toaddr, content, to, cc, bcc=none) might this:
dosend(fromaddr, to+cc, content, to, cc) t in bcc: dosend(fromaddr, t, content, to, cc, t) that send once to , cc address(es), send again each bcc address individually, appropriate bcc header. clarify dosend does: fromaddr , toaddr arguments envelope (the first , second arguments server.sendmail). to, cc, , (optional) bcc arguments headers in msg. (your code doesn't add bcc, need add if optional argument bcc provided.)
(edit: deleted comments possibility might use x-bcc. tried it, , works described above. fixed , clarified description of dosend.)
Comments
Post a Comment