首页 > 解决方案 > 如何创建在线文档以通过 python 记录用户的值?

问题描述

我需要在在线文件中记录用户机器 ID,以检查他们是否有权使用我的程序。

我尝试使用 smtplib 通过电子邮件发送此数据,但我失败了。

import smtplib

host = "smtp.gmail.com',587"
server = smtplib.SMTP(host)
FROM = "testpython@test.com"
TO = 'my_email@gmail.com'
MSG = "Subject: Test email python\n\nBody of your message!"
server.sendmail(FROM, TO, MSG)

server.quit()
print("Email Send")

我也尝试下面的代码

import smtplib

sender = 'from@fromdomain.com'
receivers = ['my_email@gmail.com']

message = """From: From Person <from@fromdomain.com>
To: To Person <my_email@gmail.com>
Subject: SMTP e-mail test

This is a test e-mail message.
"""

try:
    smtpObj = smtplib.SMTP('localhost')
    smtpObj.sendmail(sender, receivers, message)
    print("Successfully sent email")
except:
    print("Error: unable to send email")

标签: python

解决方案


推荐阅读