所以我正在按照教程在 python 中发送电子邮件,问题是它是为 python 2 而不是 python 3 编写的(这就是我所拥有的)。所以这就是我想要得到的答案 python 3 中的电子邮件模块是什么?我要获取的特定模块是:
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMETex
我也有一种感觉,当我深入到这个模块时,会有一个错误(还没有到那里,因为上面的模块给出了错误
import smtp
这是脚本:
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMETex
fromaddr = ("XXXXX@mchsi.com")
toaddr = ("XXXX@mchsi.com")
msg = MIMEMultipart
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = ("test")
body = ("This is a test sending email through python")
msg.attach(MIMEText(body, ('plain')))
import smptlib
server = smptlib.SMPT('mail.mchsi.com, 456')
server.login("XXXXX@mchsi.com", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
text = msg.as_string()
sender.sendmail(fromaddr, toaddr, text)