# Email Service

Provider-agnostic email service. Switch providers via environment variables without code changes.

## Usage

```typescript
import { sendEmail } from '@/lib/email';

await sendEmail({
  to: 'user@example.com',
  subject: 'Hello',
  html: '<p>Message body</p>',
  replyTo: 'reply@example.com', // optional
});
```

## Configuration

| Variable         | Description                            |
| ---------------- | -------------------------------------- |
| `EMAIL_PROVIDER` | `smtp` or `resend` (default: `resend`) |
| `EMAIL_FROM`     | Default from address                   |

### SMTP (MailHog, SendGrid SMTP, etc.)

```bash
EMAIL_PROVIDER=smtp
SMTP_HOST=mailhog
SMTP_PORT=1025
SMTP_USER=           # optional
SMTP_PASS=           # optional
```

### Resend API

```bash
EMAIL_PROVIDER=resend
RESEND_API_KEY=re_xxxxx
```

## Local Development

MailHog is included in Docker Compose:

- SMTP: `localhost:1025`
- Web UI: `http://localhost:8025`

Set `EMAIL_PROVIDER=smtp` to route emails to MailHog.

## Adding Providers

1. Create `lib/email/providers/<name>.ts` implementing `EmailProvider`
2. Add case to `getProvider()` in `lib/email/index.ts`
