In this tutorial, we will explain how to install Simple NixOS Mailserver on OpenBSD. Simple NixOS Mailserver is a suite of software that allows you to run your own mail server. This tutorial assumes that you have a basic understanding of OpenBSD and know how to access the command line.
The first step is to install the required packages on the OpenBSD server. Run the following command to install the packages:
doas pkg_add git gnupg curl postfix dovecot opendkim opendmarc rspamd certbot
Next, we need to install Simple NixOS Mailserver. Follow the steps below:
git clone https://gitlab.com/simple-nixos-mailserver/nixos-mailserver.git
cd nixos-mailserver
curl -sSL https://keybase.io/simple-nixos-mailserver/pgp_keys.asc | doas gpg --import
doas gpg --fingerprint BBE88A6FCB7E49A9C9B7CF319CFE6A9407F47B4E
./install.sh
After the installation is complete, we need to configure the mail server. Follow the steps below:
mail-config-example.nix
file:doas vim mail-config-example.nix
mydomain.com
to your domain nameusers
block to include the email addresses you want to usealiases
blockSave and close the file
Generate the configuration file:
./generate-config.sh mail-config-example.nix > mail-config.nix
sudo nixos-rebuild switch
Rspamd is the spam filter used by Simple NixOS Mailserver. We need to configure and start Rspamd using the following steps:
rspamd/local.d/worker-controller.inc
file:sudo vim /etc/rspamd/local.d/worker-controller.inc
bind_socket
setting to listen on localhost:bind_socket = "localhost:11333";
Save and close the file
Enable the Rspamd service:
sudo systemctl enable rspamd.service
sudo systemctl start rspamd.service
Postfix is the SMTP server used by Simple NixOS Mailserver. We need to configure and start Postfix using the following steps:
mail-config.nix
file:sudo vim /etc/nixos/mail-config.nix
smtpd_sasl_auth_enable
setting to yes
:smtpd_sasl_auth_enable = "yes";
Save and close the file
Enable the Postfix service:
sudo systemctl enable postfix.service
sudo systemctl start postfix.service
Dovecot is the IMAP and POP3 server used by Simple NixOS Mailserver. We need to configure and start Dovecot using the following steps:
mail-config.nix
file:sudo vim /etc/nixos/mail-config.nix
protocols
setting to include IMAP and POP3:protocols = [ "imap" "pop3" ];
Save and close the file
Enable the Dovecot service:
sudo systemctl enable dovecot.service
sudo systemctl start dovecot.service
DKIM and DMARC are email authentication mechanisms that help prevent email spoofing. We need to configure and start DKIM and DMARC using the following steps:
mail-config.nix
file:sudo vim /etc/nixos/mail-config.nix
Add your DKIM selector and key file path under opendkim.keys
Modify the opendmarc.report_email
setting to your email address:
opendmarc.report_email = "you@yourdomain.com";
Save and close the file
Enable the opendkim and opendmarc services:
sudo systemctl enable opendkim.service
sudo systemctl enable opendmarc.service
sudo systemctl start opendkim.service
sudo systemctl start opendmarc.service
Simple NixOS Mailserver requires an SSL certificate to secure the email traffic. We need to configure the SSL certificate using the following steps:
Generate a new SSL certificate or obtain a trusted one
Edit the mail-config.nix
file:
sudo vim /etc/nixos/mail-config.nix
sslCertificate
and sslPrivateKey
settings to the path of your SSL certificate and private key respectively:sslCertificate = "/path/to/ssl/cert";
sslPrivateKey = "/path/to/ssl/private/key";
Save and close the file
Apply the configuration changes:
sudo nixos-rebuild switch
Congratulations! You have successfully installed Simple NixOS Mailserver on OpenBSD and configured it to run a mail server. You can now start sending and receiving emails from your own mail server.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!