# Send Email Single Recipient — Twilio SendGrid

> This action sends a personalized e-mail to the specified recipient. See the docs here

- Key: `sendgrid-send-email-single-recipient`
- Type: Action (Write)
- Version: 0.1.2
- App: Twilio SendGrid (`sendgrid`) — https://pipedream.com/apps/sendgrid.md
- This page (HTML): https://pipedream.com/apps/sendgrid/actions/send-email-single-recipient
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/sendgrid/actions/send-email-single-recipient/send-email-single-recipient.mjs

## Description

This action sends a personalized e-mail to the specified recipient. [See the docs here](https://docs.sendgrid.com/api-reference/mail-send/mail-send)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `fromEmail` | `string` | Yes | The 'From' email address used to deliver the message. This address should be a verified sender in your Twilio SendGrid account. Options are loaded from the connected account. |
| `fromName` | `string` | No | A name or title associated with the sending email address |
| `toEmail` | `string` | Yes | The intended recipient's email address |
| `toName` | `string` | No | The intended recipient's name |
| `cc` | `string` | No | An array of recipients who will receive a copy of your email. Each object in this array must contain the recipient's email address. Each object in the array may optionally contain the recipient's name. Alternatively, provide a string that will JSON.parse to an array of recipient objects. Example: [{"email":"email@example.com","name":"Example Recipient"}] |
| `bcc` | `string` | No | An array of recipients who will receive a blind copy of your email. Each object in this array must contain the recipient's email address. Each object in the array may optionally contain the recpient's name. Alternatively, provide a string that will JSON.parse to an array of recipient objects. Example: [{"email":"email@example.com","name":"Example Recipient"}] |
| `personalizationHeaders` | `object` | No | An object containing key/value pairs allowing you to specify handling instructions for your email. You may not overwrite the following headers: x-sg-id, x-sg-eid, received, dkim-signature, Content-Type, Content-Transfer-Encoding, To, From, Subject, Reply-To, CC, BCC. |
| `substitutions` | `string` | No | Substitutions allow you to insert data without using Dynamic Transactional Templates. This field should not be used in combination with a Dynamic Transactional Template, which can be identified by a template_id starting with d-. This field is a collection of key/value pairs following the pattern "substitution_tag":"value to substitute". The key/value pairs must be strings. These substitutions will apply to the text and html content of the body of your email, in addition to the subject and reply-to parameters. The total collective size of your substitutions may not exceed 10,000 bytes per personalization object. |
| `dynamicTemplateData` | `object` | No | Dynamic template data is available using Handlebars syntax in Dynamic Transactional Templates. This field should be used in combination with a Dynamic Transactional Template, which can be identified by a template_id starting with d-. This field is a collection of key/value pairs following the pattern "variable_name":"value to insert" |
| `templateId` | `string` | No | An email template ID. A template that contains a subject and content — either text or html — will override any subject and content values specified at the personalizations or message level. Options are loaded from the connected account. |
| `replyToEmail` | `string` | No | The email address where any replies or bounces will be returned |
| `replyToName` | `string` | No | A name or title associated with the replyToEmail address |
| `subject` | `string` | Yes | The global or message level subject of your email |
| `content` | `string` | No | Content of the email in text/html |
| `headers` | `object` | No | An object containing key/value pairs of header names and the value to substitute for them. The key/value pairs must be strings. You must ensure these are properly encoded if they contain unicode characters. These headers cannot be one of the reserved headers. |
| `categories` | `string[]` | No | A string array of category names for this message. Each category name may not exceed 255 characters. Example: ["category1","category2"] |
| `customArgs` | `string` | No | Values that are specific to the entire send that will be carried along with the email and its activity data. Key/value pairs must be strings. Substitutions will not be made on custom arguments, so any string that is entered into this parameter will be assumed to be the custom argument that you would like to be used. This parameter is overridden by custom_args set at the personalizations level. Total custom_args size may not exceed 10,000 bytes. |
| `sendAt` | `integer` | No | An ISO 8601 formatted date-time (YYYY-MM-DDTHH:MM:SSZ) allowing you to specify when you want your email to be delivered. This may be overridden by the send_at parameter set at the personalizations level. Delivery cannot be scheduled more than 72 hours in advance. If you have the flexibility, it's better to schedule mail for off-peak times. Most emails are scheduled and sent at the top of the hour or half hour. Scheduling email to avoid peak times — for example, scheduling at 10:53 — can result in lower deferral rates due to the reduced traffic during off-peak times. |
| `asm` | `object` | No | Advanced Suppression Manager. An object allowing you to specify how to handle unsubscribes |
| `asmGroupId` | `integer` | No | Advanced Suppression Manager Group ID. The unsubscribe group to associate with this email. Will override the value set in the asm param if also set Options are loaded from the connected account. |
| `asmGroupsToDisplay` | `integer[]` | No | An array containing the unsubscribe groups that you would like to be displayed on the unsubscribe preferences page. Will override the value set in the asm param if also set. Requires asmGroupId set if this is set Options are loaded from the connected account. |
| `ipPoolName` | `string` | No | The IP Pool that you would like to send this email from |
| `mailSettings` | `object` | No | A collection of different mail settings that you can use to specify how you would like this email to be handled |
| `trackingSettings` | `object` | No | Settings to determine how you would like to track the metrics of how your recipients interact with your email |
| `numberOfAttachments` | `integer` | No | The number of attachments to be sent with the email. |
| `syncDir` | `dir` | No | SyncDir |

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

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: "sendgrid-send-email-single-recipient",
  arguments: {
    fromEmail: "From Email",
    fromName: "From Name",
  },
})
```

**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: "sendgrid-send-email-single-recipient",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    sendgrid: { authProvisionId: "apn_xxxxxxx" },
    fromEmail: "From Email",
    fromName: "From Name",
  },
})

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": "sendgrid-send-email-single-recipient",
    "configured_props": {
      "sendgrid": { "authProvisionId": "apn_xxxxxxx" },
      "fromEmail": "From Email",
      "fromName": "From Name"
    }
  }'
```

---

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