Content Management

Paperless-ngx Email Setup: IMAP Ingestion Guide

J
James Eriksson
··11 min read
Set up automatic email document ingestion in Paperless-ngx with IMAP. Learn mail rules, Gmail app passwords, troubleshooting, and best practices.
TL;DR
  • Email ingestion pulls documents from Gmail or other email providers directly into Paperless-ngx with automatic tagging and OCR.
  • IMAP is for receiving mail; SMTP is for sending (optional). Gmail requires app-specific passwords due to 2FA security.
  • Mail rules automatically tag and assign correspondents based on sender patterns using regex matching.
  • Use email ingestion for high-volume recurring documents like receipts, bills, and invoices.
  • Common mistakes include confusing IMAP with SMTP, DNS resolution failures in Docker, and using the main password instead of app passwords.

Email is the fastest way to get documents into Paperless-ngx. Forward receipts, bills, or PDFs to a designated email account, and they automatically land in your archive with tags, full-text search, and OCR applied. This guide walks you through IMAP setup, mail rule creation, and common pitfalls so you do not waste hours troubleshooting DNS issues or mixing up SMTP with IMAP.

Why Use Email to Ingest Documents into Paperless-ngx?

Your email inbox is already a document silo. Receipts pile up. Invoices get buried. Tax documents scatter across folders. Paperless-ngx turns email into a document scanner: you forward something to paperless@yourserver.com, and it auto-extracts, tags, and archives it within seconds.

This matters for small firms and freelancers because paper scanning is friction. You can photograph a receipt and email it instantly-far faster than logging into Paperless, uploading, and manually tagging. Email ingestion closes the gap between how you already work and what you need: a searchable archive.

The workflow saves time for specific document types: receipts from online retailers, monthly bills (insurance, utilities), statements, expense reports from team members, PDFs from automated systems (bank exports, vendor communications). Mail rules let you assign tags and correspondents automatically, so a receipt from Amazon lands tagged as "receipts, amazon" with the correspondent field pre-filled. You search later, find it instantly, and you never dig through email again.

This is not a replacement for manual document management. If you run a law firm and need chain-of-custody guarantees or complex workflows, email ingestion is too simplistic. But if you are running a 10-person services firm and want to stop losing invoices, email ingestion pays for itself in the first month. For the broader context of self-hosted document management systems, email is just one ingestion method-but it is the most frictionless for recurring, high-volume documents.

IMAP vs SMTP: Which One Do You Need?

This is the biggest source of confusion. IMAP and SMTP are two different protocols that do opposite things, and Paperless-ngx needs both configured correctly or neither works.

IMAP (Internet Mail Access Protocol) is for inbound mail. It allows Paperless to connect to your email server, pull new messages, extract PDF attachments, and trigger the OCR and tagging pipeline. IMAP is the protocol you configure if you want to forward bills to Paperless.

SMTP (Simple Mail Transfer Protocol) is for outbound mail. It allows Paperless to send documents back to email addresses on demand. SMTP is optional. You configure it only if you want the "email this document" button to work inside Paperless.

A common failure: someone sets up IMAP correctly, documents arrive in Paperless, but the email button in the Paperless UI does not work because SMTP was never configured. It looks like a bug. It is not. The UI simply hides the email button if SMTP is not set up.

For this guide, you will set up IMAP so documents flow in. SMTP is a bonus section if you need it. The majority of users only need IMAP: documents flowing in automatically, no manual intervention.

Step-by-Step IMAP Setup for Gmail

Gmail requires app-specific passwords because it uses two-factor authentication (2FA). You cannot use your main Gmail password directly. Here is the process:

First, verify your Gmail account has 2FA enabled. Go to myaccount.google.com, select "Security" in the left menu, and check "2-Step Verification" is on. If not, turn it on now. This takes two minutes and is mandatory for Paperless.

Next, create an app password in Gmail. Go back to Security, scroll to "App passwords," and select "Mail" and "Windows Computer" (or Mac, or Linux-it does not matter). Gmail generates a 16-character password. Copy it immediately; you will never see it again.

Now, open Paperless-ngx and navigate to the Mail tab. Click "Add account." You will see fields for server, port, username, and password. For Gmail, fill these in:

Server: imap.gmail.com Port: 993 Username: your-email@gmail.com Password: (paste the 16-character app password from Gmail) Security: select "SSL"

Leave all other fields at defaults. Click "Test connection." If the test passes, Paperless has successfully authenticated to Gmail. If it fails, the most common reasons are: (1) the wrong password (paste it exactly, including spaces if any), (2) 2FA is not enabled, or (3) you created the app password but then cleared your Gmail session. Try again.

Once the connection is live, Paperless automatically checks for new emails every 10 minutes. Create a Gmail filter to automatically label incoming mail "paperless." This keeps your Paperless inbox separate from personal mail and makes troubleshooting easier if something goes wrong.

For other providers: Outlook uses imap-mail.outlook.com (port 993, SSL). ProtonMail requires a ProtonMail Bridge app running locally. Self-hosted email (like Mail-in-a-Box) uses your server domain with port 993.

Creating Mail Rules to Filter, Tag, and Assign Correspondents

Mail rules are where email ingestion becomes powerful. A rule is a conditional trigger: if an email arrives from sender X, automatically tag it Y and assign correspondent Z.

Go to the Mail tab in Paperless. Click "Add rule." You will see:

Matching rule: Choose "Recipient" or "From" (the sender). "From" is most common for filtering by sender. Expression: This is a regex pattern. For bills from Amazon, write ".amazon." (matches any sender containing "amazon"). Assign tags: Select tags to apply. Create tags for "receipts" and "amazon" if they do not exist yet. Assign correspondent: Pick from your correspondents list (create "Amazon" if needed). Assign document type: Select "Invoice" or "Bill." Assign title from: Choose "Subject" to use the email subject line as the document title.

One gotcha: Paperless mail rules match a single condition. You cannot write "from amazon.com AND subject contains invoice." You have to create multiple rules or use broad regex patterns.

A practical example: Set one rule to match sender ".@amazon.com" and tag it "amazon, receipts." Set another rule for sender ".@utilities.com" and tag it "utilities, bills." After a few weeks, you will have a ruleset that handles 90 percent of your recurring mail automatically.

Test a rule by sending a test email that matches the condition. If the rule triggers correctly, you are done. If not, check the regex pattern or test the connection again.

Email Attachment Post-Processing and Security

After Paperless ingests an email, it can automatically clean it up. These post-processing actions prevent your inbox from ballooning:

Mark as read: Paperless marks the email as read after processing, so your inbox does not fill with "new" items. Archive folder: Move the email to an archive folder automatically. Delete: Move to trash (use this only if you are sure the attachment was processed correctly).

For security, use "archive folder" instead of "delete." Keep one month of raw emails in an archive folder. If Paperless misprocesses a document or OCR fails, you have the original email to debug. After a month, Gmail's auto-delete filters can remove the archived emails.

One security note: email attachments are an attack surface. The OCR and text extraction pipelines in Paperless are parsing and extracting text from every attachment. This is not a Paperless-specific risk-it is true for any document processing system-but do not forward emails with suspicious attachments (executables, scripts, zips containing unknown files). The golden rule: only email yourself documents you trust.

Common Mistakes and Troubleshooting

Mistake 1: Confusing IMAP with SMTP. IMAP pulls emails in. SMTP sends documents out. If you set up IMAP correctly and the email button in Paperless still does not work, you forgot to configure SMTP. This is not a bug. Set up SMTP if you want email-out functionality.

Mistake 2: DNS resolution fails in Docker. If you run Paperless in Docker on your local network, DNS to imap.gmail.com might fail because Docker containers sometimes cannot resolve external hostnames. Fix: use a different DNS server inside the container. Add --dns 8.8.8.8 to your docker run command or set dns: 8.8.8.8 in your compose file.

Mistake 3: Using the main Gmail password instead of an app password. Gmail requires app passwords for IMAP. Pasting your main password does not work, even if 2FA is off. Always generate an app password via myaccount.google.com.

Mistake 4: Email button missing from the Paperless UI. This means SMTP is not configured. The UI simply hides the button. No configuration error, just not set up. If you do not need email-out, you can ignore this entirely.

Mistake 5: Emails arrive but attachments are not extracted. Check that the email actually contains PDF or image attachments. Paperless only processes attachments, not email body text (unless you configure SMTP and have it do more). If PDFs are present, check the Paperless logs for OCR errors or permission issues on the document storage directory.

Mistake 6: Rules trigger but tags are not applied. Verify the regex pattern is correct. Test a rule by sending a test email that should match. If the rule still does not apply, check that the tags exist in Paperless. If a tag does not exist, Paperless silently skips it.

When Email Ingestion Is NOT the Right Tool

Email ingestion is fast for high-volume, low-friction document types. But it is not universal.

Do not use email ingestion for untrusted attachments. Email is a vector for malware. If you receive PDFs from unknown senders, process them manually or use a sandboxed system to preview them before forwarding to Paperless.

Do not use email ingestion if your workflow requires complex tagging. Mail rules are single-condition. If you need to apply five tags based on file content and sender and subject line, manual upload with the UI is faster. Paperless' manual upload includes bulk tagging and drag-and-drop, which may actually be more efficient for small batches.

Do not use email ingestion if your Paperless instance is not accessible from the internet (e.g., local network only). You cannot forward external email to a machine that has no public IP. In this case, use folder monitoring or manual upload.

Next Steps: Deploy and Monitor

You now have a working email ingestion setup. Documents flow in automatically, rules apply tags, and your archive grows without lifting a finger.

The next step is monitoring. Check the Paperless logs weekly to see if any emails failed to process. The logs will show IMAP connection errors, missing attachments, or OCR failures. Catching these early prevents silent data loss.

If you want to offload the operations burden-Docker updates, backups, monitoring, networking-consider managed Paperless-ngx hosting on Opsily. This frees you to focus on your business instead of managing infrastructure at 2am when IMAP stops working.

Frequently Asked Questions

Can I use Gmail in Paperless-ngx? Yes. Gmail requires an app-specific password if 2FA is enabled. Go to myaccount.google.com, select Security, and generate an app password under "App passwords." Use this 16-character password in Paperless, not your main Gmail password.

Does Paperless-ngx support multiple users forwarding to the same inbox? Yes, all forwarded emails land in the same Paperless mailbox. Mail rules apply to all incoming mail. If you need per-user tagging, use mail filters upstream in Gmail or Outlook to tag emails, then write rules in Paperless that match those tags.

Is paperless-ngx safe for handling confidential documents? Paperless-ngx is GDPR compliant and open-source (GPL-3.0), so the code is auditable. Never email confidential documents over unencrypted channels. Use IMAP with SSL (port 993) to encrypt the connection. If you handle sensitive data (medical records, financial statements), run Paperless on a private network or managed hosting with security controls.

What if I forward an email with no attachments? Paperless ignores it. Email ingestion only processes attachments (PDFs, images). Email body text is not archived. If you need to capture text, include it as a text file attachment or use manual upload.

Can I unsubscribe from mail rules? No. Mail rules apply to every matching email. If you want to exclude certain senders, write a negative regex pattern or manually archive emails you do not want tagged.

How often does Paperless check for new mail? By default, every 10 minutes. You can adjust this in environment variables. More frequent checks consume more resources; every 10 minutes is a good balance for most users.

Can I set up email ingestion without 2FA? For Gmail, app passwords require 2FA. For other providers (Outlook, self-hosted email), 2FA is optional. If your email provider does not require 2FA, you can use your main account password, but this is less secure. Enable 2FA if your provider supports it.

The Bottom Line

Email ingestion in Paperless-ngx turns a friction point (scattered email attachments) into an automated archive (tagged, searchable, OCR'd). Set up IMAP with an app password, create mail rules for your most frequent senders, and your document pipeline runs itself.

The setup takes one hour. Mail rules take another hour. After that, it scales to hundreds of documents a month with zero manual work. If you are scanning receipts, invoices, or any recurring PDF, email ingestion pays for itself in time saved.

Host Paperless-ngx Worry-Free
Skip the Docker setup and use Opsily's managed Paperless-ngx hosting on EU infrastructure.
Get Started Free

Ready to self-host your own apps?

One server. Multiple apps. No per-app fees.

Get started →