CC、BCC


  • 多創造一個想CC、BCC的名單
email_from = '[email protected]'
email_to = ['[email protected]']
email_cc = ['[email protected]']
email_bcc = ['[email protected]']
  • 把CC名單也加上去msg
msg = MIMEMultipart()
msg['Subject'] = email_subject
msg['From'] = email_from
msg['To'] = ', '.join(email_to)
msg['Cc'] = ', '.join(email_cc)
  • 把email_to、email_cc、email_bcc組成一個list
email_receiver = email_to + email_cc + email_bcc
  • 寄出對象改為 email_receiver 這樣才能讓 email_cc、email_bcc 的人真的收到
server = smtplib.SMTP_SSL(smtp_ssl_host, smtp_ssl_port)
server.login(username, password)
server.sendmail(email_from, email_receiver, msg.as_string())
server.quit()

results matching ""

    No results matching ""