电子邮件标头与smtp服务器无关。发送电子邮件时,只需将抄送和密件抄送收件人添加到toaddrs。对于CC,将它们添加到CC标头中。
toaddr = 'buffy@sunnydale.k12.ca.us'cc = ['alexander@sunydale.k12.ca.us','willow@sunnydale.k12.ca.us']bcc = ['chairman@slayerscouncil.uk']fromaddr = 'giles@sunnydale.k12.ca.us'message_subject = "disturbance in sector 7"message_text = "Three are dead in an attack in the sewers below sector 7."message = "From: %srn" % fromaddr + "To: %srn" % toaddr + "CC: %srn" % ",".join(cc) + "Subject: %srn" % message_subject + "rn" + message_texttoaddrs = [toaddr] + cc + bccserver = smtplib.SMTP('smtp.sunnydale.k12.ca.us')server.set_debuglevel(1)server.sendmail(fromaddr, toaddrs, message)server.quit()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)