📜  给 python 电子邮件中的字体颜色 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:23.449000             🧑  作者: Mango

代码示例1
import smtplib

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

msg = MIMEMultipart('alternative')

msg['Subject'] = "Link"
msg['From'] = "my@email.com"
msg['To'] = "your@email.com"

text = "Hello World!"

html = """\

  
  
    

Hello World!

""" part1 = MIMEText(text, 'plain') part2 = MIMEText(html, 'html') msg.attach(part1) # text must be the first one msg.attach(part2) # html must be the last one s = smtplib.SMTP('localhost') s.sendmail(me, you, msg.as_string()) s.quit()