更新时间:2022-12-03 10:15:39
这对我有用:
msg = MIMEMultipart()
msg['From'], msg['To'], msg['Subject'] = ... # specify your sender, receiver, subject attributes
body = 'This is the body of the email.'
body = MIMEText(body) # convert the body to a MIME compatible string
msg.attach(body) # attach it to your main message
您附加了正文
到 msg
,而 body
应该是 MIMEText
对象。
You attach the body
to the msg
, and body
in your case should be the MIMEText
object.