Kubernetes + MailKite
Kubernetes doesn't send email natively, but you can route inbound email to your cluster via MailKite webhooks. Use an Ingress-nginx annotation or a bare webhook endpoint to receive parsed email as clean JSON at any pod or service.
What you need
- A verified domain with SPF + DKIM published
- Your API key (
mk_live_…) - A Kubernetes cluster with an Ingress controller or a publicly reachable service
How it works
MailKite POSTs inbound email to your webhook URL. Your cluster processes it — create a ConfigMap, trigger a Job, or POST to an internal service. The handler runs inside your cluster, so it has direct access to Kubernetes APIs and internal networking.
Set up the webhook
Deploy a lightweight webhook receiver as a container in your cluster. This example listens on port 3000 and logs inbound email — extend it to call the Kubernetes API, update a ConfigMap, or trigger a CronJob.
// k8s-webhook.js — deploy as a container
const http = require('http');
const server = http.createServer((req, res) => {
if (req.method !== 'POST') { res.writeHead(405); return res.end(); }
let body = '';
req.on('data', c => body += c);
req.on('end', () => {
const email = JSON.parse(body);
console.log(`Inbound: ${email.from} → ${email.to} — ${email.subject}`);
// Process: create a pod, update a ConfigMap, or call an internal API
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end('{"ok":true}');
});
});
server.listen(3000); Receive inbound email
Configure your MailKite domain's webhook URL to point at your Kubernetes endpoint. Every inbound email delivers this payload:
from— sender addressto— recipient addresssubject— email subjecttext— plain text bodyhtml— HTML bodyattachments— array of file objects
Test it
curl -X POST https://your-cluster.example.com/webhook/mailkite \
-H "Content-Type: application/json" \
-d '{"from":"test@example.com","to":"k8s@yourdomain.com","subject":"Hello from MailKite","text":"Test"}' Troubleshooting
- Ensure your Ingress or LoadBalancer exposes the webhook endpoint publicly — MailKite must reach it from the internet.
- Use Cloudflare Tunnel or ngrok if your cluster is behind a firewall or private network.
- Check pod logs with
kubectl logs -l app=webhookto verify inbound requests arrive.
See the SMTP relay docs for connection details, or Inbound webhooks for the full payload.