Let Your NAS Sort Your Email Using A Container: A Thunderbird Setup Guide
I get a LOT of email in my personal and business email accounts. I was using Gmail to organize it, but Gmail had specific limitations and was cumbersome to manage.

After a bit of research, I decided to switch to Thunderbird as an email client, but also a way to filter and sort my incoming email. It's been around forever, is stable, free to use, and runs on all of my devices.
I get newsletters, promotions, and news updates that I need to read. I just don't want them competing with client messages and other important mail in my Inbox.
Thunderbird's message filters handle that nicely. The complication comes when I use several computers, plus a phone and tablet. Maintaining the same rules on every computer adds another thing to keep synchronized. And there's no easy way built into Thunderbird.
My solution was to run one instance of Thunderbird continuously in a container on my Synology NAS. It does the sorting, and my other devices access the organized mail through IMAP. I now have roughly 20 filters in that central instance that automatically organize emails into specific .
Here is how to build a similar setup with Docker and Portainer, including a few details that are easy to overlook.
How the arrangement works
The central Thunderbird instance connects to your existing mail providers through IMAP. When a rule moves a message into another server folder, that change becomes visible on your other devices.
| Component | Job |
|---|---|
| Email provider | Receives and stores your mail |
| Thunderbird container | Connects to your accounts and runs the sorting rules |
| Other computers, phones, and tablets | Read and manage the same IMAP mailboxes |
| Browser interface | Lets you configure the central Thunderbird |

The mail stays with your provider. This just adds an always-on mail client, but does not replace the provider with a mail server.
Remember to create sorting destinations inside the appropriate IMAP account. A folder under Thunderbird's Local Folders would keep the filed messages on that installation instead of making them available through the account on your other devices. Gmail presents its labels as folders in Thunderbird. We will get into the details later on in this guide.
Where this approach shines is when you want one interface for rules across different providers. If your providers' own filtering tools already meet your needs, those are simpler and run without an additional computer or container.
What you need
This guide has a few prerequisites and makes some assumptions about your set up. My host is a Synology DS1821+ NAS, but the same approach can work on other compatible Docker hosts.
This walkthrough assumes you already have:
- Docker running, with the host available in Portainer as a Docker Standalone environment.
- IMAP accounts and their sign-in details.
- A place to store Thunderbird's persistent configuration.
- An HTTPS reverse proxy and a hostname that reaches it from your network or VPN.

The example uses the community-maintained LinuxServer.io Thunderbird image. Its Selkies interface displays Thunderbird in your browser. Closing that browser tab leaves the application running inside the container. This should be verified during testing.
I use this as a private service on my network and VPN. The browser interface gives access to a desktop session and signed-in mail. Because of this it should be protected with HTTPS and a separate login.
Publishing it directly to the internet calls for stronger access controls than the basic login shown here. And I don't advise that since there are many ways to securely and easily access it remotely.
1. Choose your paths, IDs, and ports
These are examples to adapt, not universal settings:
| Setting | Example | What to check |
|---|---|---|
| Persistent host directory | /volume1/docker/thunderbird |
Your actual storage path |
| Application user ID | 1026 |
The UID of the account that will own the files |
| Application group ID | 100 |
That account's appropriate group ID |
| Timezone | America/Chicago |
Your local timezone |
| Backend TCP port | 8581 |
Availability on the Docker host. You will need to change to a different port if 8581 is taken |
| Browser hostname | thunderbird.example.com |
Your DNS and certificate |
| Reverse proxy HTTPS port | 443 |
Your proxy's existing listening configuration |

The /volume1/docker/ layout is a Synology example. Another NAS or Linux server might use /volume2/docker/, /srv/docker/, or a different location. The path must exist on the Docker host, not merely on the computer where you opened Portainer.
Make sure that this folder is on a storage pool that allows room for cached mail as well as settings. A Thunderbird profile can grow well beyond a small configuration directory. Review its Synchronization & Storage settings if mailbox size is a concern.
Check the backend port before deploying
Portainer's Containers list shows published ports. For a text listing, run this on the Docker host through SSH:
sudo docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
A mapping such as 8581->3000/tcp means host port 8581 forwards to port 3000 inside a container. The host-side number is the one to check for conflicts. A plain 3000/tcp entry does not mean host port 3000 is published.
Stopped containers may not show every configured mapping in that view. Check a particular container with:
sudo docker inspect --format '{{json .HostConfig.PortBindings}}' CONTAINER_NAME
Replace CONTAINER_NAME with its real name. Also check services outside Docker. On Linux, use sudo ss -ltn; on a Synology where that command is unavailable, use:
sudo netstat -ltn
These commands read information. They do not reserve a port. If 8581 is occupied, choose another backend port and use that number consistently in the stack and reverse proxy destination.
An existing reverse proxy can usually serve another hostname on its current HTTPS listener. You do not need to give the Thunderbird container port 443, or claim the proxy's listening port a second time.
Prepare a dedicated folder
Find the intended file owner's IDs on the host:
id YOUR_USERNAME
Use that account's actual UID and GID. The example values 1026:100 mean user ID and group ID, not process IDs.
Create a new, empty Thunderbird directory and give that account Read/Write access. On Synology, you can do this through File Station. On another Linux host, use its normal directory ownership and permission tools.
Avoid an Everyone Read/Write grant: this folder will hold Thunderbird's profile, including account credentials or tokens. On DSM, check inherited permissions as well as ownership. For this image, supply the IDs through PUID and PGID; do not assume another application's user: setting is interchangeable.
2. Create the Portainer stack
In Portainer, select the correct host, then open Stacks -> Add stack. Name it thunderbird, choose Web editor, and paste this configuration:
services:
thunderbird:
image: lscr.io/linuxserver/thunderbird:latest
container_name: thunderbird
environment:
PUID: "1026"
PGID: "100"
TZ: America/Chicago
CUSTOM_USER: mailadmin
PASSWORD: "${THUNDERBIRD_WEB_PASSWORD:?Set THUNDERBIRD_WEB_PASSWORD in Portainer}"
RESTART_APP: "true"
SELKIES_DESKTOP: "true"
volumes:
- type: bind
source: /volume1/docker/thunderbird
target: /config
bind:
create_host_path: false
ports:
- "127.0.0.1:8581:3000"
shm_size: "1gb"
stop_grace_period: 60s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"

Before deploying, change the example IDs, time zone, directory, and backend port to suit your host. The bind mount requires the directory to exist already.
Under the stack's Environment variables, add THUNDERBIRD_WEB_PASSWORD with a password you choose for the browser login. A password manager can generate a long, random value. For this example, use at least 24 letters and digits to avoid special-character substitution issues noted in the image's documentation. This is separate from your email passwords, which you enter later inside Thunderbird.
A few settings deserve explanation:
/configis the persistent mount. Keep it when replacing the container.restart: unless-stoppedrestarts the container after a host restart, provided you did not deliberately stop it.RESTART_APP: "true"separately watches the application and reopens it if it exits.SELKIES_DESKTOP: "true"adds the lightweight desktop panel and menu in supported Wayland-based images. It is optional for sorting mail; current Thunderbird images use Wayland by default.
The mapping to 127.0.0.1 is intended for a reverse proxy running directly on the same host, as DSM's does. A proxy on another machine, or in its own container, needs a different reachable backend address since its localhost is not the NAS. Adapt the network configuration accordingly.
Docker also documents a localhost-publishing limitation in releases before 28.0.0, where other devices on the same network segment may reach these ports. Keep authentication and appropriate firewall restrictions in place; do not treat the bind address as your only access control.
Click Deploy the stack. Allow time for the first image download. Check the container's logs if startup fails. The latest tag changes over time, so consult the maintainer's current documentation when installing or updating.
3. Connect the reverse proxy
For DSM's built-in proxy, open Control Panel -> Login Portal -> Advanced -> Reverse Proxy and create a rule like this:
| Area | Field | Example |
|---|---|---|
| Source | Protocol | HTTPS |
| Source | Hostname | thunderbird.example.com |
| Source | Port | 443 |
| Destination | Protocol | HTTP |
| Destination | Hostname | 127.0.0.1 |
| Destination | Port | 8581 |

If your proxy uses a custom HTTPS port, such as 4433, use that source port and include it in the browser URL: https://thunderbird.example.com:4433. The backend destination remains 8581 unless you changed it in the stack.
In Custom Header, choose Create -> WebSocket. This supplies the headers needed by the remote display. In Advanced Settings, use HTTP/1.1 upstream and set proxy read and send timeouts to 3600 seconds for long-lived sessions.
Assign a certificate that covers the hostname, and make sure DNS reaches the intended proxy from your LAN or VPN. A public DNS record does not itself determine whether a service is reachable from the internet; routing and firewall rules determine that.
The browser connection uses HTTPS. DSM forwards local HTTP to the container's port 3000, following the image maintainer's reverse proxy guidance. Opening the backend's plain HTTP address directly is not the intended browser access method.
4. Add your accounts and sorting folders
Open your HTTPS address and sign in as mailadmin with the browser password you set in Portainer. Add your mail accounts inside Thunderbird, choosing IMAP and completing the provider's sign-in process.
Create destinations under each account, such as Newsletters, Promotions, or client and project folders. Keep each account's mail in its own server folders unless you deliberately want to move mail between accounts. This is feasible, but can also be a slow process.

My main goal is to separate wanted subscriptions from messages that need attention. A promotional email I requested is not automatically junk, and filing it does not need to mark it read or delete it.
5. Build and test the filters
Open Tools -> Message Filters and choose the account the rules apply to. Start with one small rule before building out the rest.
For example, a newsletter rule can match any of several exact sender addresses and move those messages to the account's Newsletters folder. Specific newsletter addresses are often safer than matching a company's entire domain, which may also send invoices, receipts, and security notices.

Enable Getting New Mail for automatic processing. Manually Run lets you apply a rule yourself. If your version offers Periodically, every 10 minutes, that provides an additional scheduled pass; it does not make the arrival trigger wait ten minutes.
Thunderbird offers filtering before or after junk classification. After classification is useful for rules that inspect message bodies. A sender-only rule can be tested before classification when investigating a delay. Check overlapping rules and their execution order before expanding the system.
Incoming-mail filters normally act on new mail in the Inbox. They are not a continuous search of every folder. Messages routed elsewhere by provider rules, and filters triggered by sending or archiving on another device, need separate consideration.
After verifying the central setup, keep the automatic sorting rules there and disable equivalent automatic rules on your other computers. That gives you one place to maintain them and avoids competing moves.
6. Check the setting that affects sorting speed
This was an important detail in my setup: Allow immediate server notifications when new messages arrive was not enabled for Gmail.
In the central Thunderbird, open Account Settings -> [account] -> Server Settings. Check each account separately. My settings are:
| Setting | Purpose |
|---|---|
| Allow immediate server notifications when new messages arrive | Uses IMAP IDLE for prompt notice of incoming mail |
| Check for new messages every 5 minutes | Provides scheduled polling as a fallback |
| Periodic filter run every 10 minutes, where enabled | Provides an additional filter pass |

These serve different jobs. With IMAP IDLE working, Thunderbird can detect mail without waiting for the five-minute check. Sorting still depends on the client receiving and processing it; this is not a guarantee that another device will never briefly show or announce the message first.
If sorting is slow, watch the central Thunderbird instance. A message that appears there late suggests a connection or detection problem. A message that appears promptly but waits to move points toward filter processing. That distinction is more useful than changing every rule at once.
With several devices connected to Gmail, also check Google's connection limits and Thunderbird's guidance if mail detection remains unreliable.
7. Verify operation and keep a backup
Before relying on the setup, test a message matching one narrow rule. Then close the browser and confirm that another test message is sorted. Stop and start the container, and confirm that the accounts and rules remain available. Include a host-reboot test during a suitable maintenance window.
Remember that a stopped container does not stop your provider receiving mail, but sorting will be paused. Check recovery after interruptions rather than assuming the restart policy proves the whole workflow works.
For a consistent profile backup, stop the container in Portainer, back up the persistent Thunderbird directory, then start it again. Also save the stack configuration and keep the web password in your password manager. IMAP synchronization is not an independent mail backup.
Back up before updating the image. Keep the same persistent mount, and follow the image maintainer's update procedure. A recovery from a problematic upgrade should pair the previous image with its matching profile backup rather than assume an older Thunderbird can use a newly upgraded profile.

The payoff for me is one place to maintain the sorting rules. My other devices can simply access the mail, while most emails now have somewhere to go besides the Inbox. If you would like help organizing your email or setting up practical systems for your business, get in touch with Chris the Computer Guy.
Documentation and further reading
- LinuxServer.io Thunderbird image and configuration
- Selkies authentication and application watchdog
- Selkies configuration reference and optional desktop
- Portainer: adding a stack
- Docker: listing containers, port publishing, and restart policies
- Synology: reverse proxy settings
- Thunderbird: account settings, message filters, and profile backups
Interfaces and container images change; compare the examples with the current documentation before deployment.