Installing Gray Duck Mail on Fedora Server

Introduction

Gray Duck Mail is a secure email server that can be used to host your own email system. In this tutorial, we will see how to install Gray Duck Mail on a Fedora server.

Prerequisites

Step 1 - Update the System

Before proceeding with the installation of Gray Duck Mail, it is recommended to update your Fedora system to its latest version.

Make sure you are logged in as root and execute the following command:

dnf update

Step 2 - Install Required Packages

Gray Duck Mail is written in Go language and requires some packages to be installed on the system.

Execute the following command to install these packages:

dnf install golang git rsyslog 

Step 3 - Create a User

Create a user that will run the Gray Duck Mail server. You can use any name for the user, but for the sake of this tutorial, we will use the name gdm.

Execute the following command to create the user:

adduser gdm

Step 4 - Clone the Repository

Clone the Gray Duck Mail repository from GitHub:

git clone https://github.com/grayducksmtp/gdm.git

The repository will be cloned in the current directory.

Step 5 - Build the Binary

Change the directory to the cloned repository and execute the following command to build the binary:

cd gdm
go build

The binary will be built, which will take some time.

Step 6 - Copy the Binary

Copy the binary to the /usr/local/bin directory, where it can be accessed by all users:

cp gdm /usr/local/bin

Step 7 - Configure Rsyslog

Create a new Rsyslog configuration file for Gray Duck Mail:

nano /etc/rsyslog.d/gdm.conf

Add the following configuration to the file:

$template GrayDuckMailLogs,"/var/log/gdm.log"%msg%
$InputTCPServerRun 514
if $programname == 'gdm' then -?GrayDuckMailLogs
& stop

This configuration will forward the logs of Gray Duck Mail to /var/log/gdm.log file.

Step 8 - Configure Systemd

Create a new Systemd configuration file for Gray Duck Mail:

nano /etc/systemd/system/gdm.service

Add the following configuration to the file:

[Unit]
Description=Gray Duck Mail
After=network.target
Wants=network-online.target

[Service]
Type=simple
User=gdm
WorkingDirectory=/home/gdm/gdm
ExecStart=/usr/local/bin/gdm -c /home/gdm/gdm/config.yml
Restart=on-failure

[Install]
WantedBy=multi-user.target

This configuration will start the Gray Duck Mail server during the boot and restart it if it fails.

Step 9 - Configure Firewall

If you have a firewall enabled on your Fedora server, you need to allow the following ports:

Execute the following command to allow these ports:

firewall-cmd --permanent --add-service=smtp --add-service=submission --add-port=465/tcp
firewall-cmd --reload

Step 10 - Configure Gray Duck Mail

Create a new configuration file for Gray Duck Mail:

nano /home/gdm/gdm/config.yml

Add the following configuration to the file:

server:
  hostname: yourdomain.com
  port: 25
smtp:
  hostname: yourdomain.com
  port: 25
  certfile: /path/to/certfile
  keyfile: /path/to/keyfile
  banner: "220 Your domain ESMTP Gray Duck Mail"
auth:
  backend: file
  usersfile: /home/gdm/gdm/users.txt
  passhash: sha512
storage:
  backend: boltdb
  dbfile: /home/gdm/gdm/gdm.db
logging:
  level: info
  logfile: /var/log/gdm.log

Replace yourdomain.com with your domain name and the paths for the SSL certificate files.

Step 11 - Create Users

Create a new users.txt file:

nano /home/gdm/gdm/users.txt

Add the following line to the file to create a user with the username user1 and password password1:

user1:$6$Bcp...:user1

Replace the hash value ($6$Bcp...) with the hash of your password. You can generate the hash using the mkpasswd command:

mkpasswd --method=sha-512

Step 12 - Start the Server

Start the Gray Duck Mail server using the following command:

systemctl start gdm

You can check the status of the server using the following command:

systemctl status gdm

Conclusion

Congratulations! You have successfully installed and configured Gray Duck Mail on a Fedora server. You can now connect to the server using an email client and start sending and receiving emails.

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!