python 发邮件抄送,暗送(cc,bcc)代码,pythonbcc,python发邮件要抄送


python发邮件要抄送或者暗送,只需要设置message的CC和BCC对应的值即可,如下代码示例:

toaddr = '[email protected]'cc = ['[email protected]','[email protected]']bcc = ['[email protected]']fromaddr = '[email protected]'message_subject = "disturbance in sector 7"message_text = "Three are dead in an attack in the sewers below sector 7."message = "From: %s\r\n" % fromaddr        + "To: %s\r\n" % toaddr        + "CC: %s\r\n" % ",".join(cc)        + "BCC: %s\r\n" % ",".join(bcc)        + "Subject: %s\r\n" % message_subject        + "\r\n"         + message_texttoaddrs = [toaddr] + cc + bccserver = smtplib.SMTP('smtp.byrx.net')server.set_debuglevel(1)server.sendmail(fromaddr, toaddrs, message)server.quit()

评论关闭