Read man 5 master carefully:
A logical line starts with non-whitespace text. A line that starts with whitespace continues a logical line.
Usually a line which does start with the whitespace continues the last field of the table and that allows to supply argument to the command in that table.
Knowing that you can set up (override) smtpd
attributes directly in the master.cf
via the command line arguments:
1025 inet n - y - - smtpd
-o relayhost=[relay1.example.com]
1026 inet n - y - - smtpd
-o relayhost=[relay2.example.com]
Square brackets suppress MX lookups (e.g. this will use an A record of relay1.example.com
instead of looking up MX record of it and then looking A record for that name).
This way you just override the settings of main.cf
for this particular instance of the daemon.
There should be no spaces in the arguments of "-o" in the master.cf
(in particular, no spaces around "="), and you can't even use quotes for that. If you need spaces there or you just want to be able to set that up in the main.cf
, you can declare variables there and reference them in master.cf
:
main.cf
:
relayhost_1025 = [relay1.example.com]
relayhost_1026 = [relay2.example.com]
master.cf
:
1025 inet n - y - - smtpd
-o relayhost=$relayhost_1025
1026 inet n - y - - smtpd
-o relayhost=$relayhost_1026
Or, curly brackets could be used to enclose spaces; that described in the manual I linked to, but I never did that myself.
As you probably have guessed, any options can be overridden like this, and you may override multiple options. Even if you look at default master.cf
closely you may notice the (probably) commented out submission
service which uses that syntax. There are also usually other services defined that span multiple lines like this. Use it as an example.