# Create and Send Email via Mailosaur — Mailosaur

> Sends an email through Mailosaur. See the documentation

- Key: `mailosaur-create-email`
- Type: Action (Write)
- Version: 0.0.3
- App: Mailosaur (`mailosaur`) — https://pipedream.com/apps/mailosaur.md
- This page (HTML): https://pipedream.com/apps/mailosaur/actions/create-email
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/mailosaur/actions/create-email/create-email.mjs

## Description

Sends an email through Mailosaur. [See the documentation](https://mailosaur.com/docs/api)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `serverId` | `string` | Yes | The identifier of the server from which the email should be sent. Options are loaded from the connected account. |
| `to` | `string` | Yes | The verified external email address to which the email should be sent. |
| `from` | `string` | No | Optionally overrides of the message's from address. This must be an address ending with YOUR_SERVER.mailosaur.net, such as my-emails @a1bcdef2.mailosaur.net. |
| `subject` | `string` | Yes | The subject line for an email. |
| `html` | `object` | No | An object with HTML properties. Please see the documentation for more details. |
| `text` | `object` | No | An object with Plain text properties. Please see the documentation for more details. |
| `send` | `boolean` | Yes | If false, the email will be created in your server, but will not be sent. |

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

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: "mailosaur-create-email",
  arguments: {
    serverId: "Server ID",
    to: "To",
  },
})
```

**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: "mailosaur-create-email",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    mailosaur: { authProvisionId: "apn_xxxxxxx" },
    serverId: "Server ID",
    to: "To",
  },
})

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": "mailosaur-create-email",
    "configured_props": {
      "mailosaur": { "authProvisionId": "apn_xxxxxxx" },
      "serverId": "Server ID",
      "to": "To"
    }
  }'
```

---

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