# Send Email With Template — Postmark

> Send a single email with Postmark using a template See the documentation

- Key: `postmark-send-email-with-template`
- Type: Action (Write)
- Version: 0.0.6
- App: Postmark (`postmark`) — https://pipedream.com/apps/postmark.md
- This page (HTML): https://pipedream.com/apps/postmark/actions/send-email-with-template
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/postmark/actions/send-email-with-template/send-email-with-template.mjs

## Description

Send a single email with Postmark using a template [See the documentation](https://postmarkapp.com/developer/api/templates-api#email-with-template)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `templateAlias` | `string` | Yes | The template to use for this email. Options are loaded from the connected account. |
| `templateModel` | `object` | Yes | The model to be applied to the specified template to generate the email body and subject. |
| `fromEmail` | `string` | Yes | The sender email address. Must have a registered and confirmed Sender Signature. To include a name, use the format 'Full Name <sender@domain.com>' for the address. |
| `toEmail` | `string` | Yes | Recipient email address. Multiple addresses are comma separated. Max 50. |
| `ccEmail` | `string` | No | Cc recipient email address. Multiple addresses are comma separated. Max 50. |
| `bccEmail` | `string` | No | Bcc recipient email address. Multiple addresses are comma separated. Max 50. |
| `tag` | `string` | No | Email tag that allows you to categorize outgoing emails and get detailed statistics. |
| `replyTo` | `string` | No | Reply To override email address. Defaults to the Reply To set in the sender signature. |
| `customHeaders` | `string[]` | No | List of custom headers to include. |
| `trackOpens` | `boolean` | No | Activate open tracking for this email. Note: the email must have HTML Body to enable open tracking. |
| `trackLinks` | `string` | No | Activate link tracking for links in the HTML or Text bodies of this email. |
| `attachments` | `string[]` | No | Each attachment should be a string with the parameters separated by a pipe character \|, in the format: Name\|Content\|ContentType. Alternatively, you can pass a string representing an object. All three parameters are required: Name - the filename with extension, i.e. readme.txt Content - the base64-encoded string with the binary data for the file, i.e. dGVzdCBjb250ZW50 ContentType - the MIME content type, i.e. text/plain Example with pipe-separated parameters: readme.txt\|dGVzdCBjb250ZW50\|text/plain Example with JSON-stringified object: {"Name":"readme.txt","Content":"dGVzdCBjb250ZW50","ContentType":"text/plain"} |
| `metadata` | `object` | No | Custom metadata key/value pairs. |
| `messageStream` | `string` | No | Set message stream ID that's used for sending. If not provided, message will default to the outbound transactional stream. |
| `inlineCss` | `boolean` | No | By default, if the specified template contains an HTMLBody, Postmark will apply the style blocks as inline attributes to the rendered HTML content. You may opt-out of this behavior by passing false for this request field. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "postmark",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "postmark-send-email-with-template",
  arguments: {
    templateAlias: "Template",
    templateModel: "Template Model",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "postmark-send-email-with-template",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    postmark: { authProvisionId: "apn_xxxxxxx" },
    templateAlias: "Template",
    templateModel: "Template Model",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "postmark-send-email-with-template",
    "configured_props": {
      "postmark": { "authProvisionId": "apn_xxxxxxx" },
      "templateAlias": "Template",
      "templateModel": "Template Model"
    }
  }'
```

---

- App: https://pipedream.com/apps/postmark.md · All apps: https://pipedream.com/apps
