You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try sending an email, using smtplib, with the bcc header set, the bcc header is included in messages send to the "to" and "cc" addresses. According to section 4.5.3 of rfc 822:
> The contents of this field are not included in copies of the message sent to the primary and secondary recipients.
So this behavior is incorrect. It should not be up to the mail client to ignore the bcc field.
Here's a script that can replicate the problem:
#!/usr/bin/env python
importsmtplibfromemail.MIMEMultipartimportMIMEMultipartfromemail.MIMETextimportMIMETextbody="this is a test"#craft the messagefromaddr='ned@example.com'server=smtplib.SMTP('smtp.example.com', 587)
p='Hunter2!'subject="test"toaddr="foo@example.com"ccaddr="bar@example.com"bccaddr="baz@example.com"msg=MIMEMultipart()
smtplib in 2.7 doesn't know anything about RFC822 or any of the replacement RFCs. sendmail accepts a *string*, and doesn't understand or modify anything about that string except the newlines. It is your responsibility not to *add* the BCC header. What you want to do is put the BCC (and CC!) recipients in your toaddr list passed to sendmail, and *not* add a BCC header.
In Python3 smtplib has a send_message method that accepts a Message object, and that method uses the BCC to inform where to send the message and strips the header before sending. That is, smtplib's send_message method *does* implement RFC5322 behaviors.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: