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

# Email

> Send transactional emails with Resend in minutes

<Steps>
  <Step title="Create Resend Account">
    Get started:

    1. Go to [resend.com](https://resend.com) and sign up

    <Tip>
      Free tier: 100 emails/day - 3000 emails/months
    </Tip>
  </Step>

  <Step title="Get API Key">
    Generate your key:

    1. Click **API Keys** in sidebar
    2. Click **Create API Key**
    3. Name it (e.g., "Development")
    4. Permissions: **Sending access**
    5. Click **Create**
    6. Copy the key (starts with `re_`)

    Add to `.env.local`:

    ```bash .env.local theme={null}
    RESEND_API_KEY=re_xxxxx
    ```

    <Warning>
      Keep this secret. Never commit to git.
    </Warning>
  </Step>

  <Step title="Set Up Your Domain (Optional)">
    Default: emails send from `onboarding@resend.dev`

    To use your own domain:

    1. In Resend, click **Domains**
    2. Click **Add Domain**
    3. Enter your domain: `yourapp.com`
    4. Copy the DNS records
    5. Add them to your DNS provider (Cloudflare, Namecheap, etc.)
    6. Click **Verify DNS Records**

    <Accordion title="Can I skip this?">
      Yes! Resend's default domain works for testing. Add your own domain before launch for better deliverability.
    </Accordion>
  </Step>

  <Step title="Configure Sender Emails">
    Open `/config.ts` and update:

    ```typescript /config.ts theme={null}
    export const config = {
        // ... other settings
        resend: {
            fromNoReply: 'YourApp <noreply@yourapp.com>',
        	fromAdmin: 'YourName at YourApp <admin@yourapp.com>',
        	supportEmail: 'support@yourapp.com',
        },
    }
    ```

    Replace with your actual addresses.

    <Info>
      Use your domain from Step 3, or keep `@resend.dev` while testing.
    </Info>
  </Step>

  <Step title="Send Your First Email">
    Email functions are ready to use. Import and call:

    ```typescript theme={null}
    import { sendEmail } from '@/lib/resend'

    await sendEmail({
      to: 'user@example.com',
      subject: 'Welcome!',
      text: 'Thanks for signing up',
      html: '<p>Thanks for signing up!</p>',
    })
    ```

    Done! Email sent 🎉
  </Step>
</Steps>

## Email Best Practices

<CardGroup cols={2}>
  <Card title="Keep It Simple" icon="sparkles">
    Plain text + basic HTML. Most email clients don't support complex CSS.
  </Card>

  <Card title="Include Both Formats" icon="file-lines">
    Always send `text` AND `html`. Some users block HTML.
  </Card>

  <Card title="Use a Subdomain" icon="branch">
    Send from `mail.yourapp.com` instead of `yourapp.com` to protect your main domain's reputation.
  </Card>

  <Card title="Test Before Sending" icon="flask">
    Send to yourself first. Check on mobile and desktop.
  </Card>
</CardGroup>

### Improve Deliverability

<AccordionGroup>
  <Accordion title="Disable click tracking">
    Click tracking modifies links, which can trigger spam filters. Disabling it improves deliverability.
  </Accordion>

  <Accordion title="Disable open tracking">
    Tracking pixels can flag emails as spam. Disable for better inbox placement.
  </Accordion>

  <Accordion title="Match URLs to sending domain">
    Links should match your sending domain. Mismatched URLs trigger spam filters.
  </Accordion>

  <Accordion title="Set up DMARC">
    DMARC tells email providers how to handle failed authentication. Add this TXT record:

    ```
        v=DMARC1; p=quarantine;
    ```
  </Accordion>

  <Accordion title="Keep emails under 102KB">
    Gmail clips emails over 102KB. Keep body text and images small.
  </Accordion>

  <Accordion title="Avoid 'no-reply' addresses">
    Use real addresses like `support@yourapp.com`. One-way communication reduces trust.
  </Accordion>

  <Accordion title="Host images on your domain">
    Images from other domains look suspicious. Host on your sending domain.
  </Accordion>

  <Accordion title="Don't use SVG images">
    Gmail doesn't support SVG. Use PNG or JPG instead.
  </Accordion>
</AccordionGroup>

### For Marketing Emails

Add unsubscribe links (required by law):

```html theme={null}
<p style="color:#666;font-size:12px;margin-top:40px">
  Don't want these emails? 
  <a href="https://yourapp.com/unsubscribe">Unsubscribe</a>
</p>
```

## Monitor Your Emails

In Resend dashboard:

* **Emails** tab shows all sent emails
* Check delivery status
* See open/click rates
* Track bounces and complaints

<Tip>
  High bounce rate? Check domain verification and DNS records.
</Tip>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Emails not sending?">
    Check:

    * `RESEND_API_KEY` in `.env.local`
    * API key has **Sending access**
    * No typos in email addresses
    * Resend dashboard for errors
  </Accordion>

  <Accordion title="Emails going to spam?">
    Fix:

    * Verify your domain (add DNS records)
    * Use your domain, not `@resend.dev`
    * Avoid spam words: "FREE!", "URGENT"
    * Don't send too many emails too fast
  </Accordion>

  <Accordion title="Domain not verifying?">
    Common issues:

    * Wait up to 60 minutes for DNS propagation
    * DNS records must match exactly (no spaces)
    * Some DNS providers need `@` instead of domain name
    * Try verifying again after waiting
  </Accordion>

  <Accordion title="Hit rate limit?">
    Free tier: 100 emails/day

    Solutions:

    * Upgrade to paid plan
    * Batch emails instead of individual sends
    * Check usage in Resend dashboard
  </Accordion>
</AccordionGroup>
