If you are running Deskpro in a local network, you may wish to configure your helpdesk to send emails from itself instead of using an external mail server.
The following guide will explain how to configure your helpdesk and host to send emails locally.
If you are sending emails to public addresses, we strongly advise using a mail server instead, to prevent emails from being flagged as potential spam and damage to your IP reputation.
This guide does not cover anti-spam configuration, and is only intended for local environments.
Configuring a mail handler on your host
Before you start, you will need to install software to handle emails on your host (OPC) server. There are many options available, but in this guide we will use Postfix.
Installing Postfix
Postfix is often pre-installed on some operating systems, and you can check if your operating system already has postfix installed with the command postfix status
.
If the command doesn't respond with the status of the Postfix service, you may need to install Postfix.
To install on Ubuntu / Debian, run the following command:
apt install postfix copy
To install on RHEL / Rocky / Alma, run the following command:
dnf install postfix copy
You may be prompted to select the default configuration. Select the Internet Site
option.
You will then be asked to provide a domain name to qualify emails sent from the mail server. Please use the domain you wish to use in your helpdesk.
i.e. if you wish to use the email noreply@example.com
, you would need to use the domain example.com
in the prompt.
Once installed, confirm the service is running with the postfix status
command.
If you accidentally select the No Configuration
option during installation, the /etc/postfix/main.cf
file will be empty, preventing Postfix from starting.
A quick way to populate this file is to run the following command:
postconf -d > /etc/postfix/main.cf copy
This will create a file with the default safe settings.
You can then start Postfix with the following command:
systemctl start postfix copy
Checking your local subnets
To prevent the server from being used for malicious purposes, you will need to whitelist and allow emails to be sent from the Deskpro containers.
The following command should output the local subnets being used by Docker and the Deskpro containers:
docker network inspect bridge deskpro_net | grep "Subnet" copy
The default subnets in use are 172.17.0.0/16
and 172.30.0.0/16
. This guide will use these subnets in default examples.
You will also require the gateway addresses for these networks, which you can obtain with the following command:
docker network inspect bridge deskpro_net | grep "Gateway" copy
The default gateways in use are 172.17.0.1
and 172.30.0.1
. This guide will use these gateways in default examples.
Configuring Postfix
If you used the 'Internet Site' option when installing postfix, you should have a basic configuration in place. There are some minor configuration changes which are required to allow the Deskpro containers to use the mail server as a relay, which will allow emails to be sent without credentials.
First, lock postfix down to only listen on the local networks. To do this, you would need to run the following command:
postconf -e "inet_interfaces = 127.0.0.1, [::1], {gateway1}, {gateway2}" copy
You will need to replace {gateway1}
and {gateway2}
with the gateway addresses from your local subnets.
Default Example:
postconf -e "inet_interfaces = 127.0.0.1, [::1], 172.17.0.1, 172.30.0.1" copy
Then you need to whitelist the local subnets with the following command:
postconf -e "mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 {subnet1} {subnet2}" copy
You will need to replace {subnet1}
and {subnet2}
with your local subnets.
Default Example:
postconf -e "mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.17.0.0/16 172.30.0.0/16" copy
To apply these changes, you need to restart postfix:
systemctl restart postfix copy
Then confirm it has restarted succesfully
postfix status copy
Finally, you can confirm the settings are active with the following command:
postconf | grep -E "inet_interfaces\ =|mynetworks\ =" copy
Configuring the firewall
By default, your firewall may be blocking SMTP access from the container. You would need to open the ports to allow your local networks to access Postfix on the host.
The following commands should configure your firewall to allow access:
opc svc firewall add-rule --permission allow --source {subnet1} --port 25 --protocol tcp
opc svc firewall add-rule --permission allow --source {subnet2} --port 25 --protocol tcp copy
Default Example:
opc svc firewall add-rule --permission allow --source 172.17.0.0/16 --port 25 --protocol tcp
opc svc firewall add-rule --permission allow --source 172.30.0.0/16 --port 25 --protocol tcp copy
Configuring the OPC Problem Checker
If you wish to use this local mail server to send problem checker alerts to a local mailbox, you can do so now.
In the OPC Webgui, select Problems, scroll down to the Notification Settings, then use the following settings:
Host -
localhost
Port -
25
From Address - The email address you want to receive these emails from.
Allow Insecure Certificates - On
Don't forget to add the recipients, click Save Settings, then click Send Test Email to confirm the configuration works.
Configuring Deskpro
In Admin > Channels > Email > Accounts, select the account you wish to use and under Outgoing Account Details select Edit Settings.
Use the following settings in the form:
Account Type -
SMTP
Host -
host.docker.internal
Port -
25
Secure Network Connection - Disabled
Username / Password - Leave blank.
Click Test Account Settings to confirm the emails can be sent successfully, then click Save to apply.
Troubleshooting
Connection Refused
This error means Deskpro cannot access the local mail server. This may be due to Postfix not running, or the firewall is blocking the connection.
Check Postfix is running with the command postfix status
, and confirm it is listening on the correct gateway with postconf | grep "inet_interfaces ="
.
Check the firewall has rules in place for the subnets to access Port 25
with ufw status
for Ubuntu / Debian, or firewall-cmd --list-all
for RHEL / Rocky / Alma
Failed to verify certificate
The local mail server should be connect to with encryption disabled or insecure certificates allowed. Either disable the Secure Network Connection option, or enable the Allow Insecure Certificates option.
Relay Access Denied
This error means the Deskpro subnets are not whitelisted for relay access.
Confirm the subnets have been added to mynetworks
with the command postconf | grep "mynetworks ="
, then confirm that smtpd_relay_restrictions
has permit_mynetworks
set with postconf | grep "smtpd_relay_restrictions ="
Emails are sending successfully, but not being received
Your recipient mail server may be marking the emails as spam. You may need to whitelist the server's IP address to allow the emails to be delivered.
Please log in or register to submit a comment.