I have set up virtualmin (latest version) on two separate servers (both Ubuntu 18.04) with the intention of separating the webserver from the mailserver.
Do I need to fiddle with the postfix/dovecot files or is there an inbuilt feature that tells a virtualmin webserver to send/receive mail from an external virtualmin mailserver?
Good that you have decided to separate mail from web. Doing so improves web server performance - particularly for parameters such as TTFB and FCP which have become meaningful signals for SEO. I am using it as a sales & marketing feature for my web hosting services - see Fast web servers - dare to compare TTFB and FCP. This is one way Virtualmin trumps cPanel and others, which force mail + web on the same server.
You do not need to edit the config files directly. Here is how you can configure two servers to work in tandem via the options that Virtualmin offes:
In your Virtualmin web optimized server, at the time of creating virtual server for, say, domain.tld, you need just uncheck the box captioned “Accept mail for domain?”. In your Virtualmin mail optimized server, at the time of creating virtual server for domain.tld, you need to uncheck the box captioned “Enable Nginx website?” and “Enable Nginx SSL website?”.
On your Virtualmin web optimized server, in Virtualmin → Server Configuration → DNS Records, edit the MX to point to the MX of your Virtualmin mail optimized server.
Point domain.tld to DNS of the Virtualmin web optimized server.
You can now host your website on your Virtualmin web optimized server and create users / mailboxes on Virtualmin mail optimized server. It should all work except for Usermin, which you will have to abandon for Roundcube or similar.
With regards to point 2, in Virtualmin -> Server Configuration -> DNS Records, I have added the mx record in the Mail server hostname section and added a priority of 5. What should I add in the Record name section however?
In Webmin -> Postfix -> SMTP Authentication And Encryption, should I add the MX record again in the Send outgoing mail via host section or?
Yes, as well as can be expected, under the circumstances.
Record name would be “Same as domain”. I had mentioned in my original message that you edit (rather than add) the MX record… that might have been simpler.
Well, no. This is a one time setting which applies to your entire system. Configuring this will send all email leaving your system via a relay / smarthost. In Webmin → Postfix → SMTP Authentication And Encryption, you need to add the credentials of an account you have on a smarthost / relay, assuming that you do have such an account.
In summary, points 1 and 2 in my original message relate to configuring a new virtual server / domain and the last paragraph in my original message relates to a one-time configuration to define an external smarthost / relay which will be used to send out your messages.