Cannot send email from server to external emails


I have just set up virtualmin (using the automatic approach) on a fresh VPS (Ubuntu 18.04) and have finished running the Post-Installation Wizard as well as running configuration check.

I added a new virtual server and added a user for email to it. I can receive mail sent from my gmail but can’t seem to send anything from my server email to my gmail.

Whenever I try to send a test email from the server, gmail refuses the mail and I get the following error in my inbox:

<>: host[]
    said: 550-5.7.26 This message does not have authentication information or
    fails to 550-5.7.26 pass authentication checks. To best protect our users
    from spam, the 550-5.7.26 message has been blocked. Please visit 550-5.7.26 for more 550
    5.7.26 information. s71si12012776pfc.287 - gsmtp (in reply to end of DATA

What am I doing wrong?

Google has mail server’s requirement is to have a verified DKIM and SPF enabled for delivering messages. It’s also recommended to have rDNS setup for the domain sending mail. However, the later might not be obligatory.

You can enable DKIM for the domains on Virtualmin/Email Settings/DomainKeys Identified Mail page.

When I try to open Virtualmin/Email Settings/DomainKeys Identified Mail, I got a message that DomainKeys Identified Mail is not installed and if I want Virtualmin to install it and I confirmed. However, the installation failed.

The installation:

Installing the DKIM filter package ..
Installing package(s) with command apt-get -y -f install opendkim ..
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  dns-root-data libevent-2.1-6 liblua5.1-0 libopendbx1 libopendbx1-sqlite3
  librbl1 libunbound2 libvbr2
Suggested packages:
  opendkim-tools unbound
The following NEW packages will be installed:
  dns-root-data libevent-2.1-6 liblua5.1-0 libopendbx1 libopendbx1-sqlite3
  librbl1 libunbound2 libvbr2 opendkim
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 713 kB of archives.
After this operation, 2220 kB of additional disk space will be used.
Get:1 bionic/main amd64 dns-root-data all 2018013001 [5360 B]
Get:2 bionic/main amd64 libevent-2.1-6 amd64 2.1.8-stable-4build1 [133 kB]
Get:3 bionic/universe amd64 liblua5.1-0 amd64 5.1.5-8.1build2 [100 kB]
Get:4 bionic/universe amd64 libopendbx1 amd64 1.4.6-11 [24.1 kB]
Get:5 bionic/universe amd64 libopendbx1-sqlite3 amd64 1.4.6-11 [5122 B]
Get:6 bionic-updates/main amd64 libunbound2 amd64 1.6.7-1ubuntu2.2 [266 kB]
Get:7 bionic/universe amd64 librbl1 amd64 2.11.0~alpha-11build1 [10.8 kB]
Get:8 bionic/universe amd64 libvbr2 amd64 2.11.0~alpha-11build1 [12.9 kB]
Get:9 bionic/universe amd64 opendkim amd64 2.11.0~alpha-11build1 [155 kB]
Fetched 713 kB in 1s (610 kB/s)
Selecting previously unselected package dns-root-data.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 95800 files and directories currently installed.)
Preparing to unpack .../0-dns-root-data_2018013001_all.deb ...
Unpacking dns-root-data (2018013001) ...
Selecting previously unselected package libevent-2.1-6:amd64.
Preparing to unpack .../1-libevent-2.1-6_2.1.8-stable-4build1_amd64.deb ...
Unpacking libevent-2.1-6:amd64 (2.1.8-stable-4build1) ...
Selecting previously unselected package liblua5.1-0:amd64.
Preparing to unpack .../2-liblua5.1-0_5.1.5-8.1build2_amd64.deb ...
Unpacking liblua5.1-0:amd64 (5.1.5-8.1build2) ...
Selecting previously unselected package libopendbx1.
Preparing to unpack .../3-libopendbx1_1.4.6-11_amd64.deb ...
Unpacking libopendbx1 (1.4.6-11) ...
Selecting previously unselected package libopendbx1-sqlite3.
Preparing to unpack .../4-libopendbx1-sqlite3_1.4.6-11_amd64.deb ...
Unpacking libopendbx1-sqlite3 (1.4.6-11) ...
Selecting previously unselected package libunbound2:amd64.
Preparing to unpack .../5-libunbound2_1.6.7-1ubuntu2.2_amd64.deb ...
Unpacking libunbound2:amd64 (1.6.7-1ubuntu2.2) ...
Selecting previously unselected package librbl1.
Preparing to unpack .../6-librbl1_2.11.0~alpha-11build1_amd64.deb ...
Unpacking librbl1 (2.11.0~alpha-11build1) ...
Selecting previously unselected package libvbr2.
Preparing to unpack .../7-libvbr2_2.11.0~alpha-11build1_amd64.deb ...
Unpacking libvbr2 (2.11.0~alpha-11build1) ...
Selecting previously unselected package opendkim.
Preparing to unpack .../8-opendkim_2.11.0~alpha-11build1_amd64.deb ...
Unpacking opendkim (2.11.0~alpha-11build1) ...
Setting up libevent-2.1-6:amd64 (2.1.8-stable-4build1) ...
Setting up dns-root-data (2018013001) ...
Setting up librbl1 (2.11.0~alpha-11build1) ...
Setting up libopendbx1 (1.4.6-11) ...
Setting up liblua5.1-0:amd64 (5.1.5-8.1build2) ...
Setting up libvbr2 (2.11.0~alpha-11build1) ...
Setting up libunbound2:amd64 (1.6.7-1ubuntu2.2) ...
Setting up libopendbx1-sqlite3 (1.4.6-11) ...
Setting up opendkim (2.11.0~alpha-11build1) ...
groupadd: existing lock file /etc/group.lock with an invalid PID '22272
groupadd: cannot lock /etc/group; try again later.
adduser: `/usr/sbin/groupadd -g 124 opendkim' returned error code 10. Exiting.
dpkg: error processing package opendkim (--configure):
 installed opendkim package post-installation script subprocess returned error exit status 1
Processing triggers for systemd (237-3ubuntu10.39) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)
.. install failed!

Weirdly, I can seem to access the DomainKeys Identified Mail page now though.

What should I change on this page? Or should I try to fix the above failed installation first?

I tried to tick “yes” for Signing of outgoing mail enabled? in the DomainKeys Identified Mail page but I keep getting the following error:

Starting DKIM filter …
… start failed : Starting opendkim (via systemctl): opendkim.serviceJob for opendkim.service failed because the control process exited with error code. See “systemctl status opendkim.service” and “journalctl -xe” for details. failed!
DKIM setup failed!

What would be the right approach to fixing the opendkim error?