New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An email and MIME handling package - Add support to send CC of email #73957
Comments
Currently using the package we can only define emails in the 'TO' There is no support for email to be sent as CC or BCC which is useful quality in many emails. Please see if this can be added. |
The examples don't cover it, but look at the documentation for setting arbitrary mail headers such as CC. And look at smtplib.SMTP.sendmail() on sending a message to arbitrary recipients (to, cc, or bcc are all the same): |
But this is what I mean.. It shouldn't be arbitrary. |
So, you want to improve the examples? I wouldn't be opposed to that. I don't see that there's any code to change. |
I think you missundersttod. I showed the example page just so you would understand what I am talking about. Works. msg['Subject'] = 'The contents of %s' % textfile won't work. It doesn't know what is CC and BCC. |
Please see the stack overflow question: |
You need to review how SMTP works. The contents of the mail message have no bearing on where messages are sent. That's exactly how BCC works: there's nothing in the message telling you who is BCC'd, but the mail is still sent to the BCC recipients, via SMTP. Similarly, you could have the message say that someone@example.com is in the To: header, but not send it to them via SMTP. I'm on the fence about including this in the examples. In any event, this bug tracker is not a place for an email tutorial. From your SO link, there's a reference (by user xyref) to another question which explains this in detail: http://stackoverflow.com/questions/1546367/python-how-to-send-mail-with-to-cc-and-bcc. This completely explains the issue. |
"I'm on the fence about including this in the examples." Think of it this way.. Including it in the docs would have prevented this question. Thx. |
If you use smtplib.send_message in python3, it will do what you want (including stripping BCC headers before sending the message). If someone wants to create a PR to add an example of what Eric is talking about (specifying additional senders in smtplib.sendmail to match what is in the CC headers) please open a new issue with a PR (which may or may not get accepted :). I don't think it is worth doing, myself, but I won't object if others think it enhances the docs. |
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: