Gmail 阻止 python 代码尝试从亚马逊服务器登录
Gmail blocks python code trying to login from amazon server
我有一个 python 代码可以抓取一些网站并向我发送一些电子邮件。
代码在我的电脑上运行良好。现在我正在尝试 运行 亚马逊网络服务器上的相同代码。但是,google 阻止了代码。有什么解决方法吗?
import smtplib
# Send email to my personal email address
def send_email(subject, msg):
try:
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login('e******@gmail.com', 'S****')
message = 'Subject: {}\n\n{}'.format(subject, msg)
server.sendmail('e*@gmail.com', 'e*@gmail.com', message)
server.quit()
print("Success: Email sent!")
except:
print("Email failed to send.")
正如 Furas 在评论部分所回答的那样,Gmail 可能会阻止来自不受信任的程序的访问,程序员可能必须为这些程序创建一个单独的密码。 Allow less secure apps to access your Gmail account
我有一个 python 代码可以抓取一些网站并向我发送一些电子邮件。 代码在我的电脑上运行良好。现在我正在尝试 运行 亚马逊网络服务器上的相同代码。但是,google 阻止了代码。有什么解决方法吗?
import smtplib
# Send email to my personal email address
def send_email(subject, msg):
try:
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login('e******@gmail.com', 'S****')
message = 'Subject: {}\n\n{}'.format(subject, msg)
server.sendmail('e*@gmail.com', 'e*@gmail.com', message)
server.quit()
print("Success: Email sent!")
except:
print("Email failed to send.")
正如 Furas 在评论部分所回答的那样,Gmail 可能会阻止来自不受信任的程序的访问,程序员可能必须为这些程序创建一个单独的密码。 Allow less secure apps to access your Gmail account