javascript - 执行使用 python smtplib 发送的电子邮件的 Javascript

标签 javascript python html smtp smtplib

我正在练习电子邮件发送,我想知道当您使用 smtplib 和电子邮件库发送和发送电子邮件时以及当您的消息包含 HTML 代码时是否可以执行 Javascript 代码?

似乎没有任何附加内容。

HTML 文件:

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
</div>
   <p class='Test'>This is my first sentence</p>

   <script type="text/javascript">
       var list = document.querySelector('p.Test');
       list.innerHTML = "I want to change it";
   </script>
</body>
</html>

Python 代码:

import smtplib
from email.message import EmailMessage


def ConnectServer(User, Pass, Host):
    SMTPServer = smtplib.SMTP_SSL(Host)
    SMTPServer.ehlo()
    SMTPServer.login(User, Pass)
    return SMTPServer

def SendMail(Server, src, dst, data):
    msg = EmailMessage()
    msg['From'] = src
    msg['To'] = dst
    msg['Subject'] = 'Test envoi python'
    msg.add_alternative(data, 'html')
    Server.send_message(msg, src, dst)


def main():
    #Define email adresses
    me = 'AN_EMAIL@MAIL.com'
    me2 = 'AN_OTHER_EMAIL@mail.com'
    Server = ConnectServer(me, 'PASS', 'smtp.gmail.com')


    with open('HTML PATH HERE', 'r', encoding='utf8') as File:
        data = File.read()
        SendMail(Server, me, me2, data)
    pass

if __name__ == '__main__':
    main()

我希望它是清楚的。

最佳答案

据我所知我们不能,我也尝试这样做,我想在邮件中包含一个用于表格内容的搜索栏。

"No. JavaScript won't work in mails. A cool way to implement this feature 
 would be to include an image that points to your server, where you generate 
 the weather report server side and render it as an image, and return it to 
 the client.

 Note though that Gmail caches images and depending on when he does it that 
 might not be refreshed."

来源:https://www.quora.com/

关于javascript - 执行使用 python smtplib 发送的电子邮件的 Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50777852/

相关文章:

javascript - Angular 1.5(组件)-如何使用 jQuery 插件?

php - javascript 数组到 php array_sum()

python - 如何使用join方法和sort方法

python - img [y:y + h,x:x + w]坐标系的工作方式

javascript - Chrome 上的 JQUERY PHP 对于 GET 请求给出 500 错误

jquery - 无法更改按钮大小

javascript - javascript 中 getelementbyid 内的变量不起作用

asp.net - 调用 ASP.NET AJAX WebServiceProxy.invoke() Javascript 方法时出现问题

python - 坚持在 Python 中使用 Megam(nltk.classify.MaxentClassifier)

jquery - Div 不会右对齐