Prompt
How do I send password reset emails from my app?
Latest observation
Oct 23, 2026
OpenAI APIWeb search: off
To send password reset emails from your app, the usual pattern is:
1) User requests a reset
On your “Forgot password?” page, ask for the user’s email address.
2) Generate a secure, one-time token
Create a random token tied to that user, store it securely with an expiry time, and mark it as single-use.
Example properties:
- token: long random string
- user_id: the account owner
- expires_at: 15–60 minutes in the future
- used_at: null until consumed
3) Email a reset link
Send an email containing a link like:
https://yourapp.com/reset-password?token=XYZ
The link should go to a page where the user can set a new password.
4) Verify token when link is opened
When the user clicks the link:
- check the token exists
- check it hasn’t expired
- check it hasn’t been used
- identify the user associated with it
5) Let the user set a new password
After validation, allow them to enter a new password, then:
- hash the new password securely
- update the account
- invalidate the reset token immediately
- optionally invalidate other sessions/devices
6) Send the email through an email provider
Use a transactional email service instead of trying to send directly from your app server. Common options:
- SendGrid
- Mailgun
- Amazon SES
- Postmark
- Resend
Important security practices
- Don’t reveal whether an email exists in your system
- respond with something like: “If an account exists, we sent a reset email.”
- Use HTTPS for the reset link
- Make tokens long, random, and unguessable
- Expire tokens quickly
- Store tokens hashed if possible
- Rate-limit reset requests
- Log reset events for security auditing
Typical flow in practice
POST /forgot-passwordwith email- App generates reset token and emails link
- User clicks link
GET /reset-password?token=...shows formPOST /reset-passwordwith token + new password- App verifies token and updates password
If you want, I can also show you:
- a database schema for reset tokens
- example code in Node, Python, PHP, or Ruby
- how to do this with a service like Firebase, Django, Laravel, or Next.js