License: Attribution-NonCommercial-ShareAlike 4.0 International
本文出自 Suzf Blog。 如未注明,均为 SUZF.NET 原创。
转载请注明:http://suzf.net/post/422
#!/usr/bin/python # -*- coding:utf-8 -*- import smtplib from email.mime.text import MIMEText to = ['zfsu'] cc = ['zfsu','root'] bcc = ['jack'] from_addr = 'root' message_subject = "Say Hello" message_text = "Hello world" message = "From: %s\r\n" % from_addr \ + "To: %s\r\n" % ",".join(to) \ + "CC: %s\r\n" % ",".join(cc) \ + "BCC: %s\r\n" % ",".join(bcc) \ + "Subject: %s\r\n" % message_subject \ + message_text to_addrs = to + cc + bcc server = smtplib.SMTP('localhost') #server.set_debuglevel(1) server.sendmail(from_addr, to_addrs, message) server.quit()