Email & PDF Ingestion System
Invox is a Next.js application for automated email ingestion and PDF processing. It connects to IMAP/POP3 email accounts, downloads PDF attachments, stores them locally, and indexes their metadata (sender, subject, date, filename) into a PostgreSQL database. The system supports both manual and scheduled ingestion, providing a simple UI for configuration and monitoring.
- 📧 Configurable email accounts — Add, edit, or delete IMAP/POP3 connections.
- 📂 Automatic PDF ingestion — Downloads attachments into
./pdfs/. - 🗄️ Metadata storage — Persists sender, subject, date, and filenames in PostgreSQL.
- ⏱️ Manual & scheduled fetching — Trigger ingestion manually or every 5 minutes.
- 🖥️ Web UI — Manage configurations and monitor email ingestion in real time.
git clone https://github.com/gupta-nu/invox.git
cd invoxnpm installsudo apt update
sudo apt install postgresql postgresql-contribsudo -u postgres psql
ALTER USER ananya CREATEDB;
\q
createdb email_pdf_ingestionCreate a .env file in the project root:
touch .env
nano .envAdd the following (update values as needed):
DATABASE_URL="postgresql://ananya:yourpassword@localhost:5432/email_pdf_ingestion?schema=public"
IMAP_HOST="imap.your-email-provider.com"
IMAP_PORT=993
IMAP_USER="your-email@example.com"
IMAP_PASSWORD="your-email-password"npx prisma migrate dev --name initmkdir pdfsnpm run devAccess UI at: http://localhost:3000
-
Open the UI → enter:
- Email Address
- Connection Type (IMAP/POP3)
- Host (e.g.,
imap.gmail.com) - Port (993 IMAP / 995 POP3)
- Username & Password
- Manual: Click Check Emails Now
- Automatic: Runs every 5 minutes
ls ./pdfs/npx prisma studioRelevant tables:
EmailIngestionConfigPDFMetadata
invox/
├── prisma/
│ └── schema.prisma # Database schema
├── src/
│ ├── app/
│ │ ├── page.tsx # Main UI
│ │ └── api/
│ │ └── email-ingestion/
│ │ ├── route.ts # CRUD for email configs
│ │ └── check-emails/
│ │ └── route.ts # Email ingestion logic
│ └── lib/
│ ├── email-client.ts # IMAP/POP3 client
│ └── types.ts # Shared types
├── public/ # Static assets
└── pdfs/ # PDF storage
- Ensure emails have PDF attachments.
- Check logs in
npm run dev. - Confirm
pdfs/has write permissions.
psql -U ananya -d email_pdf_ingestion
sudo systemctl status postgresqlVerify .env credentials.
- Test account credentials externally.
- For Gmail, enable App Passwords.
npx prisma generate
rm -rf .next
npm run dev- Manual fetch → Use Check Emails Now
- Verify PDFs →
ls ./pdfs/ - Check logs →
npm run dev - Database check →
npx prisma studio
MIT License © 2025 Ananya Gupta