Source: https://cli.nylas.com/guides/email-to-discord-notifications

# Send Email to Discord with a Webhook (CLI)

Plenty of teams and communities live in Discord, not Slack, and want important email to land in a channel. Discord's incoming webhooks make that a one-line POST — no bot to register, host, or keep online. The Nylas CLI gives you the matching messages as JSON; a curl to the webhook posts them as rich embeds. This guide wires email to a Discord channel, formats a clean embed, and scopes it to the messages worth pinging people about.

Written by [Pouya Sanooei](https://cli.nylas.com/authors/pouya-sanooei) Software Engineer

Updated June 8, 2026

> **TL;DR:** Create a Discord channel webhook (one URL), pull matching messages with `nylas email search --json`, and POST each as an embed with `curl`. No bot to host — the webhook is a fire-and-forget endpoint. Scope the search so only the mail worth a ping reaches the channel, and run it on a schedule or trigger it from a real-time webhook.

Command references used in this guide: [`nylas email search`](https://cli.nylas.com/docs/commands/email-search), [`nylas email list`](https://cli.nylas.com/docs/commands/email-list), and [`nylas email read`](https://cli.nylas.com/docs/commands/email-read).

## How do you send email to a Discord channel?

You send email to Discord by POSTing the message to a channel webhook. Create the webhook in the channel's settings to get a URL, then pull matching mail with `nylas email search --json` and curl each message to that URL. There's no bot to register or host — an incoming webhook is a stateless endpoint, documented in the [Discord webhook docs](https://discord.com/developers/docs/resources/webhook#execute-webhook).

The webhook URL is the only credential, and it's a secret: anyone with it can post to the channel, so keep it out of source control and in an environment variable. With the URL set, a single curl turns any matched message into a channel post, and the CLI's JSON output means you're formatting structured fields, not scraping text.

```bash
# A plain-content post for one matched message
hook="$DISCORD_WEBHOOK_URL"
nylas email search "subject:incident newer_than:1h" --json --limit 10 \
  | jq -r '.[] | "**" + (.subject // "(no subject)") + "** from " + (.from[0].email // "")' \
  | while read -r line; do
      curl -s -X POST "$hook" -H "Content-Type: application/json" \
        -d "{\"content\": \"$line\"}"
    done
```

## How do you format a rich embed?

Format a rich embed by sending an `embeds` array instead of plain `content`. An embed gives you a title, a description, fields, a color bar, and a timestamp, so an email shows up as a tidy card rather than a wall of text. Map the subject to the title, the sender to a field, and a snippet of the body to the description for an at-a-glance post.

Build the embed JSON with `jq` so quoting and escaping are correct — a subject with a quote or a newline would otherwise break the payload. Discord accepts up to 10 embeds per message, so you can batch a few related emails into one post. Keep descriptions short; an embed is a notification, and a link back to the full thread beats pasting the entire body.

```bash
# One message as a rich embed
nylas email search "subject:incident newer_than:1h" --json --limit 1 \
  | jq '{embeds: [ .[0] | {
        title: (.subject // "(no subject)"),
        description: ((.snippet // "") | .[0:300]),
        color: 15158332,
        fields: [ {name: "From", value: (.from[0].email // "unknown")} ]
      } ]}' \
  | curl -s -X POST "$DISCORD_WEBHOOK_URL" \
      -H "Content-Type: application/json" -d @-
```

## How do you avoid spamming the channel?

Avoid noise by scoping the search tightly and running on the right cadence. A query like `subject:incident newer_than:1h` on an hourly schedule posts only the messages that matter, instead of mirroring the whole inbox into a channel nobody can then read. The scope of the search is your filter — make it specific.

For instant alerts, drive the same POST from a real-time webhook when a matching message arrives, rather than polling. De-duplicate on the message ID if you both poll and receive webhooks, so a message can't post twice. The Discord webhook URL is independent of the mailbox grant, so rotate it on its own if it ever leaks into a log.

## Next steps

- [Email to Slack notifications](https://cli.nylas.com/guides/email-to-slack-notifications) — the same pattern for Slack
- [Parse inbound email webhooks](https://cli.nylas.com/guides/parse-inbound-email-webhooks) — post in real time
- [Extract email data with jq](https://cli.nylas.com/guides/extract-email-data-jq) — shape the embed payload
- [Build reliable email automation](https://cli.nylas.com/guides/build-reliable-email-automation) — patterns for production
- [Full command reference](https://cli.nylas.com/docs/commands) — every flag and subcommand documented
