简体   繁体   中英

Python SMTP send email with CC

I'm using Python 2.7.3 and I want to send email with CC. Something in general like this: 在此处输入图像描述

(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 ?

“c”可能必须是这样的小写:

message['Cc'] = 'test@atte-mm.com'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM