gpt4 book ai didi

javascript - 使用python获取空白电子邮件

转载 作者:行者123 更新时间:2023-11-28 03:32:11 24 4
gpt4 key购买 nike

我正在尝试使用 python 发送电子邮件,但收到空白电子邮件,这是使用 css 文件和 js 文件

import smtplib
import urllib2
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import sys

server = "localhost"
sender = "send email id"
receivers = ["receiver email id"]
msg = MIMEMultipart('alternative')

SUBJECT = "devsmoke run"
msg['Subject'] = SUBJECT
msg['From'] = sender
msg['To'] = receivers
html = """
<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>

<!-- Latest compiled and minified CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.6/slate/bootstrap.min.css" rel="stylesheet" integrity="sha384-X9JiR5BtXUXiV6R3XuMyVGefFyy+18PHpBwaMfteb/vd2RrK6Gt4KPenkQyWLxCC" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>

<!-- Local resources -->
<link rel="stylesheet" href=".html/report.css">
<script src=".html/report.js"></script>

<!-- Reporting data -->
<script src="report.js"></script>
</head>
<body>
<div class="container-fluid" id="root"></div>
</body>
</html>
"""
part2 = MIMEText(html, "html")
msg.attach(part2)
try:
s = smtplib.SMTP(server)
s.sendmail(sender, receivers, msg.as_string())
s.quit()
print("Successfully sent email")
except Exception, err:
print(err)
print("Error: unable to send email")

我收到电子邮件,但没有任何内容。文件report.js和.html目录与此python代码位于同一目录中

最佳答案

将邮件内容添加到 MIMEMultipart 对象。

msg.attach(MIMEText(html, "html")) # You can have html or text in content

关于javascript - 使用python获取空白电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58077849/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com