Separate Mail Servers on a Per Domain basis

I have a large customer whose business has grown, and as such so has their outgoing email volume. This is in the real estate industry, so there is a lot of email going out to every ISP under the sun. I have been dealing with deliverability issues and occasionally some ISPs like MSN blocking our IP for too much mail, which then affects all of my other customers and myself included since everything is sent out through the same IP.

To fix this for this client, we are moving to sendgrid for our outgoing email for this ONE domain which will have it's own IP. This is fine for the clients to set up the outgoing server in their individual email clients, but it is not fine for outgoing email originating from the server since that uses the servers mail instead of sendgrids.

I see no option to allow an individual virtual host to use separate incoming/outgoing SMTP servers. I see you can set up postfix to use a different server, but I don't want that for all email for all domains on the server. I only want it for this one virtual domain. How can I accomplish this?

Thanks, Steve Heinsch



Howdy -- although it's not possible to do that from within Virtualmin, you can configure Postfix to use an alternate relay for some domains.

That can be done using the Postfix "sender_dependent_relayhost_maps" parameter.

That's described here:

Essentially, you'd setup something like this in the Postfix

sender_dependent_relayhost_maps = hash:/etc/postfix/sender_dependent_relayhost

And then, you'd create the file "/etc/postfix/sender_dependent_relayhost", and give it contents such as the following:

foo@example.comĀ  [x.y.z.q]:25
bar@example.comĀ  [x.y.z.q]:25

Or like this: [x.y.z.q]:25

And then run:

postmap /etc/postfix/sender_dependent_relayhost

That would cause it to relay email via the IP x.y.z.q for the domains or email addresses listed in that file.

I haven't actually done the above before, but based on the configuration examples I'm seeing, something like the above should do the trick.

This can be done using sender-dependent transport maps .. but only if you running Postfix 2.7 or later.

In Virtualmin, go to Webmin -> Servers -> Postfix Mail server, and look for the Sender Dependent Transport Mapping icon.

See also , which explains how this feature is used in Virtualmin to have outgoing email sent using a domain's private IP address.

So, Jamie and I tossed out two separate ideas there :-)

Which to use depends on what you want to do... if you just want to use an alternate IP on your own server, you could use Jamie's suggestion of Sender Dependent Transport Maps. That has the advantage of being supported by Virtualmin.

If you wish to relay via an IP on a remote server, you'd need to use the Sender Dependent Relay Host option I mentioned in the first comment above.