0

I'm using Python 2.7.3 and I want to send email with CC. Something in general like this: enter image description here

(The subject is just for example)

I have the following function:

def send_email(data):
    body = "hello world"
    message = MIMEText(body)
    message['Subject'] = "File '%s' upload data" % data['filename']
    message['From'] = 'noreply@atte-mm.com'
    message['To'] = data['send_to']
    message['CC'] = 'test@atte-mm.com'
    s = smtplib.SMTP(SMTP_HOST)
    s.sendmail(EMAIL_SENDER, [data['send_to']], message.as_string())
    s.quit()

The function works however it ignores the CC. The TO receive the email without the CC and of curse the CC receives nothing.

I didn't find anything useful in the python documentation about SMTP.

Is it possible to send a mail with CC? If not how do I make it work with two email address in the TO?

avi
  • 1,626
  • 3
  • 27
  • 45
  • 1
    You're not supplying the `CC` email to `sendmail` function. Put the `CC` email along with `data['send_to']` emails. [This question](http://stackoverflow.com/questions/1546367/python-how-to-send-mail-with-to-cc-and-bcc) might help. – xyres Mar 09 '17 at 13:15
  • But I want it to be in CC not just another recipient... Assuming this is my only option should I just do `message['To'] = data['send_to'] + 'x@x.com'` – avi Mar 09 '17 at 13:37
  • Possible duplicate of [python: how to send mail with TO, CC and BCC?](https://stackoverflow.com/questions/1546367/python-how-to-send-mail-with-to-cc-and-bcc) – omerfarukdogan Apr 01 '19 at 06:22

1 Answers1

1

The "c" might have to be lower case like this:

message['Cc'] = 'test@atte-mm.com'
miistyyy
  • 30
  • 5