My SendMail function looks like this:
MY_SMTP = #I can't show it here
def SendMail(authentication_data, email_from, email_to_list, email_cc_list, email_subject, email_message, list_file)
user_name = authentication_data["name"]
user_password = authentication_data["password"]
msg = MIMEMultipart(email_message)
server = smtplib.SMTP(MY_SMTP)
server.starttls()
emails_list_string = ", ".join(email_to_list)
emails_cc_list_string = ", ".join(email_cc_list)
msg["From"] = email_from
msg["To"] = emails_list_string
msg["Cc"] = emails_cc_list_string
msg["Subject"] = "TEST"
msg["Date"] = email.Utils.formatdate()
msg.attach(MIMEText(email_message))
server.login(user_name, user_password)
server.sendmail(email_from, emails_list_string + ", " + emails_cc_list_string, msg.as_string())
server.quit()
When I use this function and I pass a list of e-mail addresses for email_to_list, it only sends an e-mail to the first element of the list. Passing any list for email_cc_list simply adds addresses to the Cc field in the e-mail, however I think it's purely cosmetic, as the people in the Cc don't see the e-mail when I send it with this function. Basically only the first address in email_to_list ever receives the e-mail.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…