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

Viewed 65
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)

So I'm using this code from https://firebase.google.com/docs/auth/admin/email-action-links#python in django

and I'm getting this error:

NameError: name 'send_custom_email' is not defined

And nothing is mentioned in the documentation. So if anyone knows the solutions it would be great.

1 Answers
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)

The above script is used for sending an email using Sendgrid.

Related