我正在使用python2和smtplib从脚本中发送电子邮件。
我将将此电子邮件复制到“已发送”文件夹,以便能够从我的电子邮件客户端(雷鸟)看到该电子邮件。当前正在发送电子邮件,但已发送的文件夹保持不变。
从我的脚本发送的电子邮件的一部分:
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email.header import Header
from email.utils import formataddr
from email import encoders
# Connect to SMTP Server
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
server.login(smtp_login, smtp_password)
# E-mail
email_msg = MIMEMultipart()
email_msg['Content-Type'] = "text/html; charset=utf-8"
email_msg['From'] = formataddr((str(Header(u"From", 'utf-8')), email_from))
email_msg["Subject"] = Header(u"Subj", 'utf-8')
text = email_msg.as_string()
server.sendmail(email_from, email_to, text)
谢谢!