如何格式化我的电子邮件内容的 HTML 文本 (smtplib)

问题描述

我正在使用 SMTPlib 发送电子邮件,但我想用 HTML 格式化内容以使其看起来更好。这是我当前的代码:

msg = EmailMessage()  # creating an object of EmailMessage class
msg['Subject'] = 'Day 1 of the project'
msg['From'] = Sender_Email  # Defining sender email
msg['To'] = Receiver_Email  # Defining receiver email
msg.set_content(f'''<pre><h3> Hi Dani,</h3>
<p style = "font-family:candara,times,helvetica; font-size:14px;">today is day <b>1</b> since you started this project.

Here is a good quote for you
<i>Fight until the end.</i>

I wish you a good day :)

Until tomorrow,<p style = "font-family:candara,helvetica; font-size:14px; color:#FF0000;"><i>your fateful script</i></p></pre>''',subtype="html")

with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
    smtp.login(Sender_Email,Password)  # Login to SMTP server
    smtp.send_message(msg)  # Sending email using send_message method by passing EmailMessage object

还有其他方法可以格式化吗?例如通过导入 css 文件?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)