How to stop postfix from the 'local' handling of email for a domain

CentOS Linux 7.9.2009
Webmin version 1.962
Virtualmin version 6.14

I need to configure mail server settings to use a remote mail exchanger for the domain. The domain concerned is the only domain hosted on the server and we have AWS SES set-up as a smarthost and email is being routed out via SES for ‘other’ recipients without issue.

The issue we have is that email generated to the domain errors like this:

NOQUEUE: reject: RCPT from localhost[::1]: 550 5.1.1 Recipient address rejected: User unknown in local recipient table;

We need this email to be routed out as well via SES the mail is not for local delivery.

I’m not sure if I’ve overcomplicated things however I’ve tried setting up transport mapping to force external routing for a domain hosted on the server however I cannot seem to force Postfix to use AWS SES for the domain even with this extra transport mapping in place

How can I tell postfix that local delivery is not applicable for the domain and force the mail to be routed via AWS SES, as said other mail from this server is successfully being relayed via this smarthost/route?

In Virtualmin’s DNS, change the MX record of the virtual server to the actual MX record for the domain.

Hi Calport, the DNS for this domain is handled via a third-party so there is no DNS control on the server for it?

Can anyone help me with this?

You are not using the email features for this domain at all on the Virtualmin server?
Then you can just disable that under Edit Virtual ServerEnabled features and remove the checkbox for “Mail for domain enabled?”.
Save, and it should now send the mail out without checking Postfix virtual.db.

Thank you for your reply toreskev I actually already have that set well in this case unset however for some reason it is still using the Postfix virtual.db any ideas?

Might be obvious, but have you restarted Postfix after making those changes, or maybe try rebooting the server itself?

Yes as those settings have been in place for a long-time. I’ve just thought of something this server basically only hosts a series of websites (under www. and a sub-domains) for one client so we have set the overall System hostname as the clients main domain so will it be that which is causing this as the overall server thinks it is the ‘domain’?

That might be it!
I vaguely recall @Joe mentioning something about that in a thread awhile back but maybe he can confirm if this is the case?

OK, thanks!

@Joe can you help/advise me on this ideally would prefer not to have to change the System hostname which is set to the client’s primary domain can I still force email to be externally routed?

Never do that, unless you really know what you’re doing.

I see OK well I don’t really know what I’m doing or I wouldn’t be asking for assistance :wink:

Can you help guide me with the best solution on how to solve my issue @Joe

Your server is named the domain you are sending mail to. What is postfix supposed to do except deliver it to what it believes is the right destination (itself)? There are other reasons not to do this, but in your case, it is doubly problematic.

Change the name of your server, and delete the virtual map entries for this domain in /etc/postfix/virtual, and regenerate the map db if you don’t use Webmin to make that change (I don’t recall if restarting postfix will regenerate it, but the postmap command definitely will).

OK thanks @Joe am I safe to rename the server it has live sites running on it, will this cause any issues?

It won’t affect your websites.

Thank you very much @Joe :+1:

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.