Mail forwarding loop

SYSTEM INFORMATION
OS type and version EL9
Webmin version 2.303
Virtualmin version 7.30.8

I have a client with 2 business domains.
Domain1 reflects their new business name and has the website - no email yet.

Domain2 is their old business name and is setup as an alias domain and just uses the Domain1 website. At present their email is directed by DNS to their old name @ outlook.com

They are starting to get people accidentally using their new domain name for emails which has never been setup as they are not wanting the cost hassle of all their stationary etc.

As a test, I enabled email for Domain1, created a user@Domain1 and set that user to also forward email to user@Domain2 which is offsite and has VMin email disabled.

The plan was for that email to be forwarded to Domain2 at Outlook, but VMin is seeing the Alias domain and I end up with a Mail forwarding loop Message.

I can sort of understand why as an alias domain apparently shares website and email addresses, so it’s not going out of the system.

Best way to handle this? I need to keep Domain2 using Domain1 website, hopefully not with a redirect as that can mess with SEO stuff etc.

So, separate domain or sub-server, or best option for me - is there a way to force the forwarded email to go offsite?

Hello,

What are the outputs of postconf -n and hostname --fqdn on your system? Also, are you hosting both of those domains?

I host both.
I deleted the alias domain hours ago and created a new top domain with email disabled and that appears to be working for now.
The main worry is the html redirect which will mess with SEO apparently.
All of the DNS is correct and the host fqdn is correct.
Is there a better way to have both sites use the same website?

It’s literally just a matter of adding a ServerAlias to your Apache config.

So the original issue only happens when using an alias domain, but everything works fine with the top-level domain?

Bit off topic but make sure the websites have a canonical tag.

Yes, the client is thrilled and all of a sudden wants to convert all employees to using the new domain name.

I can do that manually, is there a way to do it from VMin?

That’s what adding an Alias in Virtualmin does (it also adds a DNS record, if DNS is hosted locally…and if you choose “with own mail” it also gets setup in the Postfix virtual map in such a way that it has email accounts that are independent of the parent domain). This is covered in a few places in the docs, e.g. How to Create Virtual Servers | Virtualmin — Open Source Web Hosting Control Panel

Thanks Joe, I think going forward I will be best served having 2 top level domains, hence the question about using VMin gui to set both domains to the same website.

My original post details that I was using an alias domain and why it failed for me.

So, you need an alias with no email (not automatically aliased to users in the parent domain and also not its own locally hosted email)?

It seems simpler to me just to follow Ilia and have a ServerAlias.

Yes, that’s probably true. That won’t do anything with mail…Virtualmin is probably making too many assumptions here, as I don’t see any way to make it do nothing with mail. You can either get mail independent of the parent or you can have it alias the parent, you can’t have it do nothing.