Overview
RLink uses:templates/email/for React Email templateslib/email/for sending logic and helpers- Resend for delivery
Common email flows
RLink typically sends email for:- Password reset
- Transactional notifications
- Newsletter or campaign delivery
- System-generated follow-ups
- Who receives it
- What triggers it
- Which template it uses
- Which environment variables it needs
- Whether retries are safe
Required configuration
At minimum, verify these values:| Variable | Purpose |
|---|---|
RESEND_API_KEY | Authenticates with Resend |
RESEND_FROM | Default sender address |
NEXT_PUBLIC_APP_URL | Builds links users can open |
BETTER_AUTH_URL | Optional fallback for auth-related links |
Template workflow
Use this pattern when adding a new template:- Create a React Email template under
templates/email/ - Keep the props explicit and minimal
- Render links from environment-aware URLs
- Add a sender helper in
lib/email/ - Trigger the send from the route or domain logic that owns the event
- Use clear subject lines
- Keep copy short
- Use absolute URLs
- Prefer stable props over passing whole model objects
- Avoid leaking internal IDs unless the recipient needs them
Sending flow ownership
Keep responsibilities separate:- Template: layout and copy
- Email helper: delivery provider details
- Feature logic: decides when an email should send
Local development
During development, verify:- Resend credentials are present if you expect real delivery
- Links point to the environment you are testing
- The template renders with realistic sample data
Production concerns
Verified sender
Your sender domain must be configured correctly in Resend. If it is not, delivery may fail or fall back to a lower-trust sender.Link correctness
Password reset and other action emails fail in practice when links point to:localhostfrom production- The wrong Vercel preview URL
- A different protocol than the deployed app
Retry safety
If a route retries after a timeout, you may accidentally send duplicate emails. Decide whether the send should be:- safe to repeat
- deduplicated
- queued
Sensitive content
Do not include secrets, raw tokens, or internal-only notes in templates or logs.Edge cases
Preview deployments
Preview URLs change. If a preview build sends a real email, the recipient may get a link that expires or points to the wrong environment.Spam and reputation
Even valid mail can land in spam. If users report missing email, verify:- sender domain reputation
- SPF / DKIM / DMARC setup
- exact recipient address
- provider dashboard delivery status
Broken personalization
If a template expectsuser.name or another field and the value is missing, the email can render poorly. Validate required template props before sending.
Campaign scale
Newsletter or bulk mail flows have different constraints than password reset. Think about rate limits, batching, unsubscribe behavior, and auditability.Debugging checklist
If email does not arrive:- Confirm the feature actually triggered the send
- Check server logs for provider errors
- Verify
RESEND_API_KEYandRESEND_FROM - Check the provider dashboard
- Open the delivered message and test every link
- Verify the message did not land in spam
Best practices
- Keep templates simple
- Centralize provider calls in
lib/email/ - Generate absolute links from trusted env values
- Protect against duplicate sends
- Test both template rendering and delivery behavior
Next steps
Authentication
Password reset and auth-related mail flows
Testing
Validate templates, links, and retries
Deployment
Production configuration and secrets
Troubleshooting
Delivery failures and common errors
