Projects/SnappyMail Webmail (Multi-account)
Mail

SnappyMail Webmail (Multi-account)

A single web interface to manage your own domain email, 126, and yeah.net simultaneously, usable on both mobile and desktop.

What It Is

I set up a self-hosted domain email for xiejun-server.top using docker-mailserver on a Hong Kong VPS, and I also still have two old accounts, 126 and yeah.net. I installed one email client on my phone and another on my work computer, and with so many accounts it became too much to manage. So I simply put SnappyMail webmail on the VPS: open one URL and I can send and receive email from all three accounts at once.

SnappyMail is essentially still a standard IMAP/SMTP client; it just moves the interface into the browser. The real difficulty has nothing to do with receiving mail; it is all about compatibility: when logging in, 126 / yeah.net validate the IMAP ID command. Native clients that do not send this command are directly rejected with "Unsafe Login", so I patched ImapClient.php to add the ID information during the handshake. On the outside, Caddy is used as a reverse proxy and automatically issues Let's Encrypt certificates, so both inbound and outbound traffic use HTTPS.

Current Status

Running. For the self-hosted domain, incoming mail goes through Dovecot on port 993, and outgoing mail leaves the network through the Brevo relay because outbound port 25 is blocked on the Tencent Cloud VPS; 126 and yeah.net connect directly using authorization codes. It works in both mobile and desktop browsers, so there is no need to fiddle with client configuration anymore.

Features

  • 一个网页入口同时管理自建域名邮箱、126、yeah.net 三个账号
  • 给 SnappyMail 的 IMAP 客户端打补丁,登录时发送 ID 命令,解决网易邮箱“Unsafe Login”拒登
  • Caddy 反向代理 + 自动 HTTPS,证书由 Let's Encrypt 签发
  • 后端直接复用 docker-mailserver 的 IMAP 993 / SMTP 465·587,不改邮箱服务本身
  • 响应式界面,手机与电脑浏览器都能用,无需安装 App

Stack: SnappyMail · Docker · Caddy · PHP · IMAP · SMTP · Let's Encrypt

Deployment Steps

1. Prerequisites

First, add an A record for the domain, for example mail.xiejun-server.top, pointing to your VPS public IP, and confirm that ports 80/443 are reachable, because Caddy needs HTTP-01 to obtain certificates. Also prepare the existing email accounts: the IMAP address and password for the self-hosted domain email, and the client authorization codes for NetEase accounts.

2. Start the Container

Start a SnappyMail container according to compose.yaml. Expose the web port only on the Docker internal network, and do not map it directly to the host's public network. Usually, only the volume path and timezone need to be changed.

3. Reverse Proxy and HTTPS

Add a section to Caddyfile:

mail.xiejun-server.top {
    reverse_proxy snappymail:8888
    encode zstd gzip
}

After caddy reload, Caddy will automatically obtain and renew certificates, and browser access should be HTTPS directly.

4. Apply the IMAP ID Patch

Overwrite the corresponding ImapClient.php in the container with patches/ImapClient.php. A more robust approach is to COPY it during image build to avoid losing the patch when the container is recreated; if you only overwrite it once with docker cp, it will be gone after recreation.

5. Configure Email Accounts

Open https://mail.xiejun-server.top/?admin. After logging in with the initial admin account, the first thing is to change the password. Then configure each email account under Domains:

  • Self-hosted domain: IMAP mail.xiejun-server.top:993 SSL/TLS, SMTP mail.xiejun-server.top:465 SSL/TLS (or 587 STARTTLS); username is the full email address.
  • 126 / yeah.net: fill in the server address and port according to the provider's instructions (usually 993 / 465 over SSL); the password must be the client authorization code generated in the webmail, not the login password.

6. Verification

Log in to each account via the normal login page, confirm the inbox loads properly and emails can be sent; then reply from an external mailbox to confirm both sending and receiving work.

Notes

  • Be sure to use HTTPS; do not transmit email passwords over plaintext HTTP.
  • Do not use default credentials on the admin panel for a long time, and do not expose it to the public internet without restriction.