Self-hosted AI email assistant on Linux (n8n + Ollama)
- Models & engines
- Ollama with llama3.1:8b
- Key gotcha
- Prompt injection via email can manipulate classification or drafts
What they built
A full guide to an email assistant that reads, categorizes, drafts replies, extracts action items and routes messages, without sending email content to any external AI service.
n8n polls the mailbox and orchestrates; Ollama does classification, summarization and drafting on infrastructure you control.
Setup
- n8n via Docker Compose (or native with systemd)
- Ollama with llama3.1:8b
- Any IMAP/SMTP server (Postfix/Dovecot, Exchange, Gmail…)
How it works
- IMAP trigger every 2 minutes
- A code node cleans the body and truncates it to 2,000 chars
- Ollama classifies into support, sales, billing, spam, internal or newsletter at temperature 0
- A switch node forwards or files the email
- Separate workflows draft replies and extract action items as JSON
Results & numbers
- 3-8 s per email; 500 emails/day is about 67 minutes of processing
- 85-95% classification accuracy with an 8B model; few-shot examples push it above 90%
Gotchas
- Prompt injection via email can manipulate classification or drafts
- Never log full email bodies
- Process sequentially; Ollama handles one request at a time best
Do it yourself
- Install n8n (Docker) with extra_hosts so it reaches Ollama on the host
- Pull llama3.1:8b
- Build IMAP trigger → clean body → Ollama classify → Switch
- Add a draft-reply workflow that saves drafts only
- Configure an error workflow that moves failures to a 'processing-failed' folder
Classify this email into exactly one category: support, sales, billing, spam, internal, newsletter.
From: {{ $json.from }}
Subject: {{ $json.subject }}
Body: {{ $json.body }}
Respond with only the category name, nothing else.Similar setups
Ollama next to n8n on a CPU-only VPS: measured speed and RAM
A developer measured how fast Ollama runs Llama 3.x models on an 8-vCPU VPS with no GPU, and how much RAM a self-hosted n8n really uses beside it, and published the raw numbers.
Serving a local model on Kubernetes on your own laptop with kind and Ollama
Alex Jones wrote a tested guide to running Ollama in a kind cluster on CPU, Intel Arc, NVIDIA and AMD, then using the served model with k8sgpt to explain cluster failures without any data leaving the machine.
A one-script Ubuntu install that stands up Ollama and Open WebUI as a private ChatGPT in the browser
HendGrow’s guide 50 ships a Bash installer that detects NVIDIA GPU or CPU, deploys pinned Ollama and Open WebUI with Docker Compose on Ubuntu 24.04, pulls a small starter model, and opens the UI on port 3000.
Connecting a self-hosted Ollama server to WordPress, and why localhost fails
John Rotherham, who works on a WordPress SEO plugin, walks through pointing WordPress AI features at your own Ollama server instead of a cloud API key, including where Ollama must run, how to lock down its unauthenticated port, and how to test from PHP.