Python 尝试使用firebase SDK在django中生成密码重置电子邮件链接时出错
所以我在django中使用这个代码 我得到一个错误:Python 尝试使用firebase SDK在django中生成密码重置电子邮件链接时出错,python,django,firebase,firebase-authentication,Python,Django,Firebase,Firebase Authentication,所以我在django中使用这个代码 我得到一个错误: name错误:未定义名称“发送自定义电子邮件” 文档中没有提到任何内容。因此,如果有人知道解决方案,那就太好了。sg=SendGridAPIClient(os.environ[“SENDGRID\u API\u KEY]”) email = 'user@example.com' link = auth.generate_password_reset_link(email, action_code_settings) # Construct p
name错误:未定义名称“发送自定义电子邮件”
文档中没有提到任何内容。因此,如果有人知道解决方案,那就太好了。sg=SendGridAPIClient(os.environ[“SENDGRID\u API\u KEY]”)
email = 'user@example.com'
link = auth.generate_password_reset_link(email, action_code_settings)
# Construct password reset email from a template embedding the link, and send
# using a custom SMTP server.
send_custom_email(email, link)
html_content=f”“”
你好,
按照此链接重置密码
{link}
如果您没有要求重置密码,可以忽略此操作
电子邮件
"""
信息=邮件(
发送电子邮件=xyz@gmail.com,
from_email=电子邮件('abc@gmail.com“,“ABC系统”)
subject=“重置ABC系统的密码”,
html\u内容=html\u内容
)
尝试:
响应=sg.send(消息)
打印(响应状态\ U代码)
除HTTPError作为e外:
打印(电子邮件)
上述脚本用于使用Sendgrid发送电子邮件。sg=SendGridAPIClient(os.environ[“Sendgrid\u API\u KEY]”)
html_content=f”“”
你好,
按照此链接重置密码
{link}
如果您没有要求重置密码,可以忽略此操作
电子邮件
"""
信息=邮件(
发送电子邮件=xyz@gmail.com,
from_email=电子邮件('abc@gmail.com“,“ABC系统”)
subject=“重置ABC系统的密码”,
html\u内容=html\u内容
)
尝试:
响应=sg.send(消息)
打印(响应状态\ U代码)
除HTTPError作为e外:
打印(电子邮件)
上面的脚本用于使用Sendgrid发送电子邮件
sg = SendGridAPIClient(os.environ["SENDGRID_API_KEY"])
html_content = f"""
<p>Hello,</p>
<p>Follow this link to reset password</p>
<p>{link}</p>
<p>If you didn't ask to reset the password, you can ignore this
email.</p>
"""
message = Mail(
to_emails=xyz@gmail.com,
from_email=Email('abc@gmail.com', "ABC System")
subject="Reset your password for ABC System",
html_content=html_content
)
try:
response = sg.send(message)
print(response.status_code)
except HTTPError as e:
print(e.message)