Main Virtual domain with Google MX and Postfix for other virtual servers

Hi, I’m trying to make this setup work: is the name of our server (its actually an alias for the in /etc/hosts)
-the mx of points to googles smpt (dig shows: 21599 IN MX 0
-the rest of the virtual servers use postfix to relay via our provider’s relayhost (relayhost =

This is working fine for the virtual servers except our main virtual server. When some external domain sends an email to our main domain it gets received correctly in gmail. But when a local virtual server tries to send us an email to our main domain it gets:
Recipient address rejected: User unknown in local recipient table.

I’ve been searching in previous forum entries and found similar situations but still can’t sort it out .
This is our postfix/
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
compatibility_level = 2
home_mailbox = Maildir/
mailbox_command = /usr/bin/procmail
mydestination = $myhostname, localhost.$mydomain, $mydomain
myhostname =
mynetworks_style = subnet
myorigin = $mydomain
readme_directory = no
relayhost =
sender_bcc_maps = hash:/etc/postfix/bcc
smtp_tls_security_level = dane
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_CAfile = /etc/postfix/
smtpd_tls_cert_file = /etc/letsencrypt/live/
smtpd_tls_key_file = /etc/letsencrypt/live/
smtpd_tls_security_level = may
virtual_alias_maps = hash:/etc/postfix/virtual

I’ve tried removing $mydomain from mydestination and even setting a blank mydestination and the the mails sent from virtual servers to our main domian works and reach our gmail account, but also every mail send to any virtual server arrives at our gmail account!

Then I found this post [Solved] Main Virtual domain with Google MX and Postfix not working with a very similar situation and the answer they found was to remove the main domain from Virtualmin according to this suggestion You’d just want to make sure to use a name like “server.domain.tld” for the server, and not put “domain.tld” under Virtualmin control. While not strictly necessary to do that, it helps keep things clean and prevent followup problems
That seems a bit risky for our production server, but if it’s really necessary we’ll try to do it. We wanted to check before going for this option.
In case it helps, our main virtual server was migrated from a Cpanel account.

Thanks in advance for any tips

We also tried via transport_maps = hash:/etc/postfix/transport with no success…

We found another post where deleting the virtual server was recommend.
the thing would be managing the DNS and www parts of our maindomain… would they need to be done manually? or?

clearing out our actual setup in virtualmin:

-main virtual server (
hosting DNS and www

–virtual sub server (
serving as our main email server for the rest of the virtual servers and also as webmail

Hello matias-tecnosoul,

have you changed the MX record in DNS setting for the Domain to point to google ?

Also not Sure about this but please read and then try the mail relay plugin

Hello, thathwamasi, yes, we have the MX records pointing to google. Actually the external domains deliver to it correctly, The “only” domains that have issues deliviering to it are the virtualservers hosted in the same Virtualmin working as NS, mail server and lamp.
I’ll check that link.

Hi again, I’ve checking that link and it says it’s outdated, and I couldn’t find if there’s an uptodate version.
Is that plugin “Mail Relay Plugin” still available?

hi, we finally seem to have found the solution.
the issue was indeed our main domain being treated as local by Postfix. It wasn’t necessary to delete the virtual server with our main domain but to remove $mydomain from mydestination according to this post.

We have tried this before but it didnt work as I mentioned above. I’m not sure what else we have done in the middle of this test but the point is: it’s working :slight_smile:

Thanks a lot to the Virtualmin community!!