On this page
Where does webmail fit in a mail setup?
Webmail is only a client: it reads mail over IMAP and hands outgoing messages to an SMTP server, so the mail server behind it decides whether delivery works. If that server is on BitcoinVPS, ask support with a ticket whether outbound port 25 is open before building on it, and request reverse DNS (PTR) in the same ticket. Where 25 is not available, the mail server should forward everything through an authenticated relay on port 587, as shown in the SMTP relay guide. SnappyMail itself always submits on 587 with the user's login, so nothing on this page needs port 25.
You can host SnappyMail on the mail server itself (for example one built with Postfix and Dovecot) or on a separate small server. A1-1 is enough for a handful of users; it uses very little memory because each request is short lived PHP.
Install Nginx and PHP
The versionless meta packages pull the PHP release that matches your system: 8.3 on Ubuntu 24.04, 8.1 on Ubuntu 22.04, 8.2 on Debian 12 and 8.4 on Debian 13.
sudo apt update
sudo apt install nginx php-fpm php-curl php-mbstring php-xml php-zip php-intl php-gd php-sqlite3 unzip
php -v
ls /run/php/Note the socket name that ls /run/php/ prints, for example php8.3-fpm.sock; the Nginx block below uses it. For a deeper look at pools and tuning, see PHP and PHP-FPM.
How do I download and unpack SnappyMail?
The project publishes a tarball of the newest release at a fixed address.
sudo mkdir -p /var/www/snappymail
cd /tmp
wget https://snappymail.eu/repository/latest.tar.gz
sudo tar xzf latest.tar.gz -C /var/www/snappymail
sudo find /var/www/snappymail -type d -exec chmod 755 {} +
sudo find /var/www/snappymail -type f -exec chmod 644 {} +
sudo chown -R www-data:www-data /var/www/snappymail
ls /var/www/snappymailYou should see index.php, a snappymail folder holding the versioned code and a data folder. The data folder will hold settings, the admin password and caches, which is why it must never be served to browsers.
Write the Nginx server block
Create /etc/nginx/sites-available/snappymail with the following, adjusting the socket name:
server {
listen 80;
listen [::]:80;
server_name webmail.example.net;
root /var/www/snappymail;
index index.php;
client_max_body_size 25m;
location ^~ /data {
deny all;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
}Enable it and test:
sudo ln -s /etc/nginx/sites-available/snappymail /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxCreate an A record for webmail.example.net pointing to 198.51.100.24 (and AAAA to 2001:db8:4f2a::24) as described in the DNS records tutorial.
How do I add HTTPS and open the firewall?
Allow web traffic and request a certificate with the Nginx plugin, which also adds the redirect to HTTPS.
sudo ufw allow OpenSSH
sudo ufw allow "Nginx Full"
sudo ufw enable
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d webmail.example.net
sudo certbot renew --dry-runRenewal runs automatically from a systemd timer. More options are in the certbot guide.
Sign in to the admin panel and add your domain
Open https://webmail.example.net/?admin. The first visit writes a random admin password to a file; read it on the server:
sudo cat /var/www/snappymail/data/_data_/_default_/admin_password.txtLog in as admin with that password and change it right away under Security, where you can also turn on two factor login for the admin. Then go to Domains, add example.net and fill in:
- IMAP:
mail.example.net, port 993, SSL/TLS - SMTP:
mail.example.net, port 587, STARTTLS, use authentication - Sieve (optional): port 4190 if your Dovecot runs ManageSieve
Use the built in Test button; green results for IMAP and SMTP mean the connection and certificate are fine. Remove the example domains that ship enabled if you do not need them.
How do I check that users can read and send mail?
Visit https://webmail.example.net/, log in with a full address such as deploy@example.net and its mailbox password, and send yourself a message. Then send one to an outside address. If the outside message stays in the mail server queue with a timeout to a remote port 25, the problem is outbound delivery on the mail server, not SnappyMail; set up the 587 relay there. Confirm that the data folder is blocked:
curl -I https://webmail.example.net/data/
sudo tail -n 20 /var/log/nginx/error.logThe curl call must return 403 Forbidden.
Keep SnappyMail current
The admin panel shows when a new version exists and can update in place if the web user may write to the folder. Alternatively, repeat the download and unpack steps; your settings in data are kept. Update PHP and Nginx with your normal package updates, consider automatic security updates, and add Fail2ban rules against repeated login failures. SnappyMail logs failed logins when you enable auth logging in the admin panel, and those lines are what Fail2ban can watch.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about SnappyMail webmail
Can SnappyMail connect to a mailbox on another server?
Yes. Add that domain in the admin panel with its IMAP and SMTP hosts. The webmail server only needs outbound access to ports 993 and 587.
Does webmail need port 25?
No. SnappyMail submits on 587 with the user login. The mail server behind it is what needs outbound delivery, so ask support by ticket about port 25 there and use a 587 relay if needed.
Where are user settings stored?
In the data folder under /var/www/snappymail. Include it in your backups and keep it blocked from the web.
Can I run it next to Roundcube?
Yes, on a different hostname or path. Both are plain IMAP clients and do not interfere with each other.
Which PHP version does SnappyMail need?
PHP 7.4 or newer. Every Ubuntu and Debian release covered here ships a newer version, so the default php-fpm package is fine.