> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shipfastai.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Email configuration with Resend and Brevo

> Configure transactional email in Shipfastai with Resend. Send verification, welcome, and password reset emails, and test locally without a real API key.

Shipfastai sends transactional emails through [Resend](https://resend.com) — a developer-focused email API. Emails are optional: if you leave `RESEND_API_KEY` unset, the application starts normally and logs a warning instead of sending. This makes local development easier because you can register and verify accounts without a real email provider.

## Resend setup

To enable email sending, create a free Resend account at [resend.com](https://resend.com), then add your API key and sender address to `.env`:

```bash .env theme={null}
RESEND_API_KEY=re_xxxxxxxxxxxxxxxxxxxx
FROM_EMAIL=noreply@yourdomain.com
```

| Variable         | Required | Description                                                                           |
| ---------------- | -------- | ------------------------------------------------------------------------------------- |
| `RESEND_API_KEY` | No       | Your Resend API key. Starts with `re_`. Leave empty to disable email.                 |
| `FROM_EMAIL`     | No       | The sender address shown in all outgoing emails. Must be a verified domain in Resend. |

<Tip>
  Resend's free tier allows 3,000 emails per month and up to 100 emails per day. This is more than enough for development and early-stage production use.
</Tip>

## Email types sent

Shipfastai sends three types of transactional emails automatically:

| Trigger                      | Email sent           | Description                                                                                                                                |
| ---------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| User registers               | Verification email   | Contains a link to `{FRONTEND_URL}/verify-email?token=…`. The token expires after `VERIFICATION_TOKEN_EXPIRE_HOURS` (default: 24 hours).   |
| User verifies email          | Welcome email        | Sent immediately after successful verification. Includes a link to the dashboard.                                                          |
| User requests password reset | Password reset email | Contains a link to `{FRONTEND_URL}/reset-password?token=…`. The token expires after `PASSWORD_RESET_TOKEN_EXPIRE_HOURS` (default: 1 hour). |

The `FRONTEND_URL` variable controls the base URL used in all email links. Make sure it matches your deployed frontend address in production.

## Customizing email templates

Email templates are defined in `backend/app/core/email.py` as inline HTML strings inside three methods on the `EmailService` class:

| Method                      | Email                |
| --------------------------- | -------------------- |
| `send_verification_email`   | Verification email   |
| `send_welcome_email`        | Welcome email        |
| `send_password_reset_email` | Password reset email |

To customize a template, open `backend/app/core/email.py` and edit the `html` variable inside the corresponding method. The templates are plain HTML strings — you can replace them with any HTML you like, including full branded designs.

For example, to change the verification email subject line:

```python backend/app/core/email.py theme={null}
return self._send(to_email, "Confirm your account - MyApp", html)
```

If you want to use a templating library like Jinja2, install it and render the template before passing the resulting HTML string to `self._send`.

## Testing locally

You have two options for testing email flows during local development:

**Option 1: Leave `RESEND_API_KEY` empty (recommended)**

When `RESEND_API_KEY` is not set, the `EmailService` logs the would-be email to the console instead of sending it. You can still test the full registration flow — check the backend logs to see the verification token URL.

```
WARNING  Email not configured (missing RESEND_API_KEY). Would have sent to=user@example.com subject=Verify your email - Shipfastai
```

**Option 2: Use a Resend test API key**

Resend supports sending emails to your own verified address using a real API key in test mode. Add your `re_` key to `.env` and set `FROM_EMAIL` to your verified sender.

```bash .env theme={null}
RESEND_API_KEY=re_your_real_key
FROM_EMAIL=you@yourdomain.com
```
