Prompt
How do I send account confirmation emails?
Latest observation
Oct 14, 2026
OpenAI APIWeb search: off
To send account confirmation emails, you generally need to:
-
Create a unique confirmation token
- Generate a secure, random token when the user signs up.
- Store a hashed version of the token in your database with an expiration time.
-
Build a confirmation link
- Include the token in a URL like:
https://yourapp.com/confirm-email?token=...
- Include the token in a URL like:
-
Send the email
- Use an email service/provider such as:
- SendGrid
- Mailgun
- Amazon SES
- Postmark
- Resend
- Send an email containing the confirmation link and instructions.
- Use an email service/provider such as:
-
Verify the token when clicked
- When the user opens the link, look up the token, check it hasn’t expired, and confirm the account if valid.
-
Mark the email as verified
- Update the user record in your database.
- Invalidate the token so it can’t be reused.
Basic flow
- User signs up
- Your app creates user record as unverified
- Generate token
- Send confirmation email
- User clicks link
- Backend verifies token
- User email marked verified
Best practices
- Make tokens single-use and short-lived.
- Use HTTPS links.
- Don’t reveal whether an email exists if someone requests a resend.
- Allow users to resend confirmation emails.
- Make sure your email provider is configured with proper SPF, DKIM, and DMARC for deliverability.
Example email content
Subject: Confirm your account
Body:
Thanks for signing up!
Please confirm your email address by clicking this link:
https://yourapp.com/confirm-email?token=ABC123
This link expires in 24 hours.
If you want, I can also show you:
- a Node.js example
- a Python/Django example
- a Rails example
- a database schema for confirmation tokens