簡體   English   中英

嘗試使用 firebase ZF20E3C5E54C0AB3D37AZ5D660B63 生成 django 中的密碼重置 email 鏈接時出錯

[英]Getting Error when trying to Generate password reset email link in django using firebase SDK

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)

所以我在 django 中使用來自https://firebase.google.com/docs/auth/admin/email-action-links#python的代碼

我收到了這個錯誤:

NameError: name 'send_custom_email' is not defined

文檔中沒有提到任何內容。 因此,如果有人知道解決方案,那就太好了。

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)

上述腳本用於使用 Sendgrid 發送 email。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM