# Groundmail with Strapi

Use [`strapi-provider-email-groundmail`](https://www.npmjs.com/package/strapi-provider-email-groundmail) as the email provider for Strapi 5 or Strapi 4. Password resets, account confirmations and every `strapi.plugin('email')` send then go out through Groundmail.

## 1. Install

```bash
npm install strapi-provider-email-groundmail
```

```bash
GROUNDMAIL_API_KEY=gm_your_key_here
```

## 2. Configure the email plugin

```ts
// config/plugins.ts
export default ({ env }) => ({
  email: {
    config: {
      provider: 'strapi-provider-email-groundmail',
      providerOptions: {
        apiKey: env('GROUNDMAIL_API_KEY'),
      },
      settings: {
        defaultFrom: 'Acme <noreply@yourdomain.com>',
        defaultReplyTo: 'support@yourdomain.com',
      },
    },
  },
})
```

`defaultFrom` must be on a domain you have [verified in Groundmail](https://docs.groundmail.dev/domains). Restart Strapi, then send a test from **Settings → Email** in the admin panel.

## 3. Send from your code

```ts
await strapi.plugin('email').service('email').send({
  to: 'user@example.com',
  subject: 'Welcome to Acme',
  html: '<p>Thanks for signing up.</p>',
  text: 'Thanks for signing up.',
})
```

Besides Strapi's `from`, `to`, `cc`, `bcc`, `replyTo`, `subject`, `text` and `html`, a send can pass:

| Field | Purpose |
|-------|---------|
| `attachments` | `[{ filename, content, contentType }]`, content as a string or Buffer (set `encoding: 'base64'` for base64 strings) |
| `template` | `{ id, variables }` to send a [Groundmail template](https://docs.groundmail.dev/templates) instead of `html`/`text` |
| `tags` | `{ name: value }` tags for filtering and webhooks |
| `headers` | Extra email headers |
| `idempotencyKey` | Send once, even when your code retries |
| `scheduledAt` | ISO 8601 time to send later |

## Provider options

| Option | Purpose |
|--------|---------|
| `apiKey` | Groundmail API key. Falls back to `GROUNDMAIL_API_KEY` |
| `baseUrl` | Override the API base URL |

## Source

[Groundmail/strapi-provider-email-groundmail](https://github.com/Groundmail/strapi-provider-email-groundmail)
