# Send Single Email with Template — SMTP2GO

> Send a single email with SMTP2GO using a pre-defined template and data object (See docs here)

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

## Description

Send a single email with SMTP2GO using a pre-defined template and data object [(See docs here)](https://apidoc.smtp2go.com/documentation/#/POST%20/email/send)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `subject` | `string` | Yes | Email subject. |
| `templateId` | `string` | Yes | The ID of the pre-defined template in SMTP2GO. Options are loaded from the connected account. |
| `fromEmail` | `string` | Yes | The sender email address. To include a name, use the format 'Full Name <sender@domain.com>' for the address. |
| `toEmail` | `string[]` | Yes | Recipient email address. Max 50. |
| `ccEmail` | `string[]` | No | Cc recipient email address. Max 50. |
| `bccEmail` | `string[]` | No | Bcc recipient email address. Max 50. |
| `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. Each attachment should be a string with the parameters separated by a pipe character \|, in the format: header\|value. Alternatively, you can pass a string representing an object. Both parameters are required: header - the header key name, i.e. some-header value - the string value of the header, i.e. the-value Example with pipe-separated parameters: some-custom-header\|the-value Example with JSON-stringified object: {"header":"some-custom-header","value":"the-value"} |
| `attachments` | `string[]` | No | List of attachments to include. 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: filename - the filename with extension, i.e. readme.txt fileblob - the base64-encoded string with the binary data for the file, i.e. dGVzdCBjb250ZW50 mimetype - the MIME content type, i.e. text/plain Example with pipe-separated parameters: readme.txt\|dGVzdCBjb250ZW50\|text/plain Example with JSON-stringified object: {"filename":"readme.txt","fileblob":"dGVzdCBjb250ZW50","mimetype":"text/plain"} |
| `ignoreFailures` | `boolean` | No | Should this action ignore failures to send an email? |

## 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": "smtp2go",
      },
    },
  },
)

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: "smtp2go-send-single-email-with-template",
  arguments: {
    subject: "Subject",
    templateId: "Template ID",
  },
})
```

**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: "smtp2go-send-single-email-with-template",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    smtp2go: { authProvisionId: "apn_xxxxxxx" },
    subject: "Subject",
    templateId: "Template ID",
  },
})

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": "smtp2go-send-single-email-with-template",
    "configured_props": {
      "smtp2go": { "authProvisionId": "apn_xxxxxxx" },
      "subject": "Subject",
      "templateId": "Template ID"
    }
  }'
```

---

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