我使用本地服务器上的flask成功地发送了包含smtplib库的邮件。但是,当我尝试在HEROKU服务器上进行部署时,它会遇到类似
的错误
内部服务器错误
服务器遇到内部错误,无法完成您的请求。服务器过载或应用程序出现错误。
这是我的代码
import smtplib
from flask impot Flsak
try:
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
s.login("emailid@gmail.com", "password")
unique_pass = "Your Password " + password
s.sendmail("emailid@gmail.com", uemail, unique_pass)
s.quit()
pd = password
# return password
mycol.insert_one({"_id": uid, "Name": uname, "Email":uemail, "Password":password })
except (gaierror, ConnectionRefusedError):
print('Failed to connect to the server. Bad connection settings?')
except smtplib.SMTPServerDisconnected:
print('Failed to connect to the server. Wrong user/password?')
except smtplib.SMTPException as e:
print('SMTP error occurred: ' + str(e))