Get your API key
All integrations Messaging

Discord + MailKite

Discord is where communities communicate. Use MailKite to forward inbound email as Discord messages — support requests, alerts, and notifications appear in your server channel.

What you need

  • A verified domain with SPF + DKIM published
  • Your API key (mk_live_…)
  • Discord server with a webhook URL (Server Settings → Integrations → Webhooks)

How it works

MailKite POSTs inbound email to a webhook handler that sends a Discord embed via the webhook URL. The email subject becomes the embed title, the sender and recipient are shown as inline fields, and the body fills the description — all in MailKite's brand blue.

Set up the webhook

Deploy this handler as a serverless function or worker. It formats inbound email as a Discord embed and posts it to your channel. Set DISCORD_WEBHOOK_URL as an environment variable.

discord-webhook.js
// Discord inbound email → channel embed handler

async function handleInbound(email) {
const webhookUrl = process.env.DISCORD_WEBHOOK_URL;

const embed = {
embeds: [{
title: email.subject || 'New inbound email',
color: 0x6ea8fe,
fields: [
{ name: 'From', value: email.from, inline: true },
{ name: 'To', value: email.to, inline: true },
],
description: email.text?.substring(0, 2000) || '_No body_',
footer: { text: 'MailKite inbound' },
}],
};

const res = await fetch(webhookUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(embed),
});
return res.json();
}

Receive inbound email

Configure your MailKite domain's webhook URL to point at your handler. Every inbound email delivers this payload:

  • from — sender address
  • to — recipient address
  • subject — email subject
  • text — plain text body
  • html — HTML body
  • attachments — array of file objects

Test it

test
curl -X POST https://your-worker.example.com/mailkite-inbound \
-H "Content-Type: application/json" \
-d '{"from":"alert@example.com","to":"alerts@yourdomain.com","subject":"Server alert","text":"CPU at 95%"}'

Troubleshooting

  • Discord webhooks are per-channel; create one in Server Settings → Integrations → Webhooks.
  • Max embed description is 4096 characters — the handler truncates longer email bodies.
  • If the webhook URL is revoked, Discord returns a 404 — regenerate it in Server Settings.

See the SMTP relay docs for connection details, or Inbound webhooks for the full payload.