How to setup multiple domains to send mail each from their own mailserver?

Trying to setup mail from multiple mail servers without any luck. My main domain – let’s call it maindomain.com – is setup to use the main (the only) Postfix mailserver at mail.maindomain.com. Works fine.

My virtual domain – virtualdomain – does currently appear to send mail correctly from its own domain address… this was accomplished via canonical address mapping inside Postfix. However, while mail does appear to come from “user@virtualdomain”, when looking at the mail headers, the mail server is clearly defined as “mail.maindomain”. This is sloppy.

I’ve setup the MX record for virtualdomain to point to mail.virtualdomain. This made no difference in the sending-server info, it just allowed me to login to user@virtualdomain via my mail client.

I’ve bashed my head against Postfix’s obscure documentation for several hours, looking for a configuration setting that will accomplish this. Haven’t found anything that will alter the “Received from: mail server” line to a virtual domain hosted on the same server.

Any advice on what I’m doing wrong? Do I need to somehow setup a second Postfix mail server, which will probably be a configuration nightmare?

Foul

(edit: had to remove all the “.coms”'s above because apparently “new users” here can only post two links. Sigh.)

It’s working how it is intended. It’s a good idea to set an SPF record for each virtual domain to authorize maindomain to send mail for it.

Sounds like you are wanting effectively for there to be a mail host for each virtualdomain - I think what you are wanting is to set up Postfix SNI. I think support for SNI is in Postfix 3.4. How to set it up - no idea and Google doesn’t show any great results.

Also - SNI support for POstfix, I don’t think the latest version of Virtualmin “supports” it yet or what plans there are for it.

Sorry couldn’t be more help.

Dibs

Thanks for the advice! I have my virtual domain SPF record pointing to my IP address, which should be sufficient (I think?). Online mail checkers don’t seem to have any issue with the SPF record, though I guess I do need to setup DMARC / DKIM for the virtual domain as well, as they couldn’t use my main domain’s apparently.

I’ll look into Postfix SNI, but since it would probably be a command line operation from what you’re saying (besides upgrading Webmin’s Postfix version 2.10 to 3.4, which smells of disaster), I think I’ll just live with the slight inconvenience of having a different domain appear as the mailserver in the message header.

Foul

For people stumbling upon this later, it appears that a solution is here:

In the “update” portion of the accepted answer, with the edits to master.cf. It apparently requires multiple IP addresses, which I don’t have, so this will remain unverified for now.

Fou;

This is not sloppy. In email headers, mail will show as originating from Virtualmin’s hostname. If you use Postfix configured for hosting multiple domains for shared hosting on a server without Virtualmin then mail will still show as originating from the hostname of the server. This is not sloppy, there are valid reasons for this and this is how Virtualmin is intended to function.

It may be how Virtualmin is intended to function, and it may be how things would work without Virtualmin in the picture… but I disagree with you; it’s sloppy. Though admittedly this is solidly a Postfix issue and has really nothing to do with Virtualmin.

Especially with the plethora of all the “canonical” and “alias” mapping configuration settings in Postfix, the fact that you cannot “alias” a mailserver (for a virtual domain you’re hosting) is at the very least an odd omission. It would seem that the only solution (other than possibly the multiple-IP-address thing above) would be to register a domain name that only serves as the server hostname, in order to preserve the anonymity between shared domains on your server.

Foul

That’s exactly what some of us do when we configure Virtualmin. I use vps01.indiax.com as my hostname on Virtualmin and my virtual server is calport.com; my clients use their respective domains with virtual servers created for them. We all use POP3 / IMAP / SMTP with incoming & outgoing server set to vps01… and the hostname in the header of email is also vps01… which is fine with all concerned. I am able to do this because I own two domains.

If I wanted everything under one domain, as many do, I would create vps01.calport.com as hostname and my virtual server would be calport.com; with this configuration my clients and I would use POP3 / IMAP / SMTP with incoming & outgoing server set to vps01.calport.com just like the big boys - Google etc. - get their clients do.

If you have used your client’s domain as hostname for your Virtualmin server @FoulFoot and you wish to offer shared hosting as a service then you are in all kinds of trouble WRT ‘preserve the anonymity between shared domains on your server’.

Good advice – thank you!

Foul