Skip to content
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

Closed
Jack mannequin opened this issue Mar 9, 2017 · 9 comments
Closed

An email and MIME handling package - Add support to send CC of email #73957

Jack mannequin opened this issue Mar 9, 2017 · 9 comments
Labels
docs Documentation in the Doc dir topic-email type-feature A feature request or enhancement

Comments

@Jack
Copy link
Mannequin

Jack mannequin commented Mar 9, 2017

BPO 29771
Nosy @warsaw, @ericvsmith, @bitdancer, @jack

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:

assignee = None
closed_at = <Date 2017-03-09.13:59:09.141>
created_at = <Date 2017-03-09.13:10:10.587>
labels = ['type-feature', 'invalid', 'expert-email', 'docs']
title = 'An email and MIME handling package - Add support to send CC of email'
updated_at = <Date 2017-03-09.14:01:02.676>
user = 'https://github.com/Jack'

bugs.python.org fields:

activity = <Date 2017-03-09.14:01:02.676>
actor = 'r.david.murray'
assignee = 'docs@python'
closed = True
closed_date = <Date 2017-03-09.13:59:09.141>
closer = 'Nonickname'
components = ['Documentation', 'email']
creation = <Date 2017-03-09.13:10:10.587>
creator = 'Nonickname'
dependencies = []
files = []
hgrepos = []
issue_num = 29771
keywords = []
message_count = 9.0
messages = ['289291', '289292', '289293', '289294', '289295', '289296', '289297', '289298', '289299']
nosy_count = 5.0
nosy_names = ['barry', 'eric.smith', 'r.david.murray', 'docs@python', 'Nonickname']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue29771'
versions = ['Python 2.7']

@Jack
Copy link
Mannequin Author

Jack mannequin commented Mar 9, 2017

Currently using the package we can only define emails in the 'TO'
as shown here:
https://docs.python.org/2/library/email-examples.html#email-examples

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.

@Jack Jack mannequin added the type-feature A feature request or enhancement label Mar 9, 2017
@ericvsmith
Copy link
Member

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):
https://docs.python.org/2/library/smtplib.html#smtplib.SMTP.sendmail

@Jack
Copy link
Mannequin Author

Jack mannequin commented Mar 9, 2017

But this is what I mean.. It shouldn't be arbitrary.
When you define CC you want him as CC not as another one in the TO.
This is why I said this is enhancement request.

@Jack Jack mannequin reopened this Mar 9, 2017
@ericvsmith
Copy link
Member

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.

@ericvsmith ericvsmith added the docs Documentation in the Doc dir label Mar 9, 2017
@Jack
Copy link
Mannequin Author

Jack mannequin commented Mar 9, 2017

I think you missundersttod. I showed the example page just so you would understand what I am talking about.
Let me explain it better:
msg['Subject'] = 'The contents of %s' % textfile
msg['From'] = me
msg['To'] = you

Works.

msg['Subject'] = 'The contents of %s' % textfile
msg['From'] = me
msg['To'] = you
msg['CC'] = x
msg['BCC'] = y

won't work. It doesn't know what is CC and BCC.
This is why I opened this request to modify the package to support it.

@Jack
Copy link
Mannequin Author

Jack mannequin commented Mar 9, 2017

Please see the stack overflow question:
http://stackoverflow.com/questions/42696100/python-smtp-send-email-with-cc

@ericvsmith
Copy link
Member

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.

@Jack
Copy link
Mannequin Author

Jack mannequin commented Mar 9, 2017

"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.
It can be just a side note it doesn't have to be a whole example.

Thx.

@Jack Jack mannequin closed this as completed Mar 9, 2017
@bitdancer
Copy link
Member

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-email type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants