How to Build a Raspberry Pi Email Server
The Raspberry Pi is an incredibly powerful and versatile device. It's suitable for everything from a basic desktop and retro gaming console to a home theatre PC. But notably, because of its low power draw and small footprint, the Pi makes an excellent server. You can create a Raspberry Pi NAS (network-attached storage) device, smart home hub, VPN server, or even web server. Learn how to build a Raspberry Pi email server!
Why the Raspberry Pi Makes a Great Email Server
A Raspberry Pi email server is a fantastic project. Because the Raspberry Pi runs Linux operating systems (OSes) ranging from Debian and Ubuntu to Arch and Manjaro, you can easily install compatible email server software. Plus, the Pi itself is incredibly energy efficient so it's suitable for an always-on environment. And a small footprint means you can fit your Raspberry Pi virtually anywhere. Finally, with the Pi Zero and Zero W clocking in at $5 USD, and a mere $35 for the Raspberry Pi 4 2GB RAM model, it's cost-effective.
Why use the Raspberry Pi as an email server:
- Energy efficient
- Small footprint
- Runs Linux
What You'll Need for a Raspberry Pi Email Server - Parts List
A Raspberry Pi email server doesn't require much more than a Raspberry Pi, a few peripherals, and some software. You'll need a Raspberry Pi board, and while I recommend the Raspberry Pi 4, the Pi 0 and 0 W should suffice since an email server doesn't require much horsepower. Additionally, you'll need a compatible Raspberry Pi power supply unit (PSU), optional but recommended case, input devices such as a keyboard and mouse, an HDMI display, and active Internet connection. On the software side, you'll need a Raspberry Pi compatible Linux distribution (distro) and email server software.
Raspberry Pi email server parts list:
- Raspberry Pi (Raspberry Pi 4 recommended)
- Case (optional, recommended)
- Linux OS
- Email server software
- microSD card (for housing an OS)
- Peripherals (keyboard, mouse)
- HDMI cable
- Internet connection
- HDMI-enabled display (monitor, TV, projector)
Total cost: $5+ USD. You can use a Raspberry Pi Zero which clocks in at $5, a Pi Zero W for $10, or go all the way up to the Raspberry Pi 4 8GB for $75. Personally, I suggest using a Pi 4 2GB which retails for $35. All software should be free.
How to Make a Raspberry Pi Mail Server
A Raspberry Pi mail server is pretty easy to set up. Citadel is a fairly user-friendly method of accomplishing a Pi email server set up. Learn how to create an email server with the Raspberry Pi!
How to Install Citadel Email Server on the Raspberry Pi
Citadel is a user-friendly mail server solution that's Raspberry Pi compatible. As with any software installation, it's best to first run an update:
sudo apt update
sudo apt upgrade
After that, install the required packages to compile Citadel locally:
sudo apt install build-essential curl g++ gettext shared-mime-info libssl-dev zlib1g-dev
Next up, install Citadel mail server for the Pi:
curl http://easyinstall.citadel.org/install | sudo bash
You'll eventually see a prompt to accept Citadel's terms and conditions. Hit Y, and Enter to continue with the installation. Then, you'll be queried on whether or not you'd like the script to install additional packages required by Citadel. Select Y, and Enter.
Now, it's time to configure Citadel. You'll be asked to enter a username for the admin user. By default, that's admin and you can either enter a new value or hit Enter to leave the Citadel email server username unchanged.
Similarly, the installation process prompts you fo enter an admin password. The default password is citadel and you can enter a new value or hit Enter to leave it unchanged. It's optional but a security best practice to at least change the password.
Once you've set a username and password, you'll need to pick a user for Citadel to run under. The default user is root, so either enter a new value such as citadel, or leave it unchanged. It's best to create a new user rather than run Citadel email server as root.
Citadel lets you enter a specific IP address for your Raspberry Pi email server to listen in on. At default, Citadel listens on all addresses, so you can leave this unchanged and hit Enter, or select a specific port. I left mine on the default settings.
You'll need to pick an authentication method. Your options are:
0. Self-contained authentication
1. Host system integrated authentication
2. External LDAP - RDC 2307 POSIX schema
3. External LDAP - MS Active Directory schema
By default, option 0, self-contained authentication, is selected. Unless you need to, leave this unchanged. If you'd like to use a host system integrated authentication method, or external LDAP choices, enter the corresponding number and hit Enter. Otherwise, just leave it at 0 and press Enter.
Lastly, choose a port for the Citadel web user-interface (web UI). If you're running a web server like Apache or WordPress, you might want to set the HTTP port to 8080, and HTTPS port as 8433. If you aren't running another web server, you could leave the HTTP port as 80 and HTTPS as 443. When that's finished, you should be all ready to start using Citadel on the Raspberry Pi!
When you've successfully installed Citadel email server on the Raspberry Pi, it's time to actually set it up. Head to your Raspberry Pi's IP address either on the Pi itself or from a different computer on the same network as your Pi. You can find your Raspberry Pi's IP address with:
In a browser, head to http://RASPBERRY PI IP ADDRESS/. Then, the Citadel login page should pop up and prompt you for your user name and password. If that's left unchanged, you'll enter root and citadel, but if you changed these to custom variables, use those instead.
After logging in, you should see the main Citadel email server dashboard. In the top right-hand portion of the screen, you should see a button reading "Make this my start page" that you can select if you want to.
Head under Administration in the bottom left-hand sidebar. There, you can make a slew of different changes such as adding domain names and Internet mail configurations, viewing the outbound SMTP queue, configuring replication with other Citadel servers, adding, removing, and editing user accounts, or editing site-wide configurations.
Select Edit site-wide configuration and enter some information. What you input depends on your specific set up, but you'll need to fill out a node name, add a fully qualified domain name, such as mail.customdomain.com, and a human-readable domain name.
Under SMTP-servers, find out the SMTP ports being used. You'll need to port forward those. Then go under System Administration Menu, choose Domain names and Internet mail configuration, and you can add more domain names to your Citadel mail server. Under Local Host Aliases, add any domain you like, for instance electromaker.io, and click Add. Once that's through, head back under Administration, and hit Restart Now under the Shutdown Citadel menu.
There's a ton you can configure in Citadel, so I suggest after finishing your installation that you poke around for a bit and check out all of its various settings.
Make a Raspberry Pi Mail Server Final Thoughts
Using a Raspberry Pi as an email server is a cost-effective solution. It's cheap, low power, and takes up virtually no space. Although it's definitely a project for power users, as the average occasional email sender will be better off with Gmail or, *gasp*, even Yahoo, it's a fun and functional Raspberry Pi project. Even if you don't really have much of a use case, this is a great means of hands-on learning about Linux, servers, and the Raspberry Pi.
Your turn: what are you using your Raspberry Pi for?
Leave your feedback...