npm package: @mservicestech/strapi-email-provider-postmark
Description: Strapi Email service provider for Postmark
Author: mServices sp. z o. o.
Latest version: 0.0.2

# @mservicestech/strapi-email-provider-postmark

[Strapi](http://strapi.io/) email service for [Postmark](https://postmarkapp.com/)

# Prerequisites

You will need to have the plugin `strapi-plugin-email` installed in you Strapi project.

# Installation

```console
# using yarn
yarn add @mservicestech/strapi-email-provider-postmark

# using npm
npm i @mservicestech/strapi-email-provider-postmark
```

# Configuration

| Variable                        | Type   | Description                                                                                                                                                                   | Required | Default   |
| ------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- |
| `provider`                      | string | The name of the provider you use                                                                                                                                              | yes      |           |
| `providerOptions`               | object | Provider options                                                                                                                                                              | yes      |           |
| `providerOptions.apiKey`        | string | Postmark API key. Please refer to [Postmark docs](https://www.npmjs.com/package/postmark) for more                                                                            | yes      |           |
| `settings`                      | object | Settings                                                                                                                                                                      | no       | {}        |
| `settings.defaultMessageStream` | string | Send through a specific message stream. Please refer to [Postmark docs](https://postmarkapp.com/support/article/1207-how-to-create-and-send-through-message-streams) for more | no       | undefined |
| `settings.defaultFrom`          | string | Default sender mail address                                                                                                                                                   | no       | undefined |
| `settings.defaultTo`            | string | Default receiver mail address                                                                                                                                                 | no       | undefined |
| `settings.defaultReplyTo`       | string | Default address the receiver is asked to reply to                                                                                                                             | no       | undefined |
| `settings.defaultVariables`     | object | Default set of variables to be used in template emails                                                                                                                        | no       | {}        |

### Example

Path - `config/plugins.js`

```javascript
module.exports = ({ env }) => ({
  // ...
  email: {
    config: {
      provider: "@mservicestech/strapi-email-provider-postmark",
      providerOptions: {
        apiKey: "your-postmark-api-key",
      },
      settings: {
        defaultMessageStream: "my-stream",
        defaultFrom: "john.doe@example.com",
        defaultTo: "john.doe@example.com",
        defaultReplyTo: "code@example.com",
        defaultVariables: {
          sentBy: "strapi",
        },
      },
    },
  },
  // ...
});
```

### Usage

Call the `send` function on the email service, as you would for any strapi email service.

```javascript
await strapi.plugins.email.services.email.send({
  to: "john.doe@example.com",
  text: "Hello John",
});
```

To send an email via a template, set `templateId` or `templateAlias` (and `variables`) to use the `sendEmailWithTemplate` method.

```javascript
await strapi.plugins.email.services.email.send({
  to: "john.doe@example.com",
  templateAlias: "code-your-own",
  variables: {
    name: "John",
  },
});
```