Enable the SMTP server to specify the port and whether to do an MX lookup for Relay Host
Migrated from: https://tracker.clearos.com/view.php?id=241 and https://tracker.clearos.com/view.php?id=243
Reported by: maeztro and Peter Baldwin
When adding a relay host with port (in the format host:port), the SMTP Server page doesn't validate the presence of the port, thus adding an invalid value to the relayhost Postfix configuration parameter. According to Postfix documentation:
"In the case of SMTP, specify a domain name, hostname, hostname:port, [hostname]:port, [hostaddress] or [hostaddress]:port. The form [hostname] turns off MX lookups."
Because the SMTP Server page doesn't validate the presence of a port on the host string it adds the relay host as [relayhost:port], which is incorrect and breaks the relay host configuration. When a port is present it must be added as [relayhost]:port or relayhost:port.
Attached to this report is a patch that fixes this issue, looking if the relay host being added contains a string in the form "host:port" and if it does then it sets relayhost = [host]:port.
Currently, MX lookups are disabled on the outbound mail relay feature. In some circumstances, users may want to use MX lookups instead of specifying a specific relay. See forum thread http://www.clearfoundation.com/component/option,com_kunena/Itemid,232/catid,14/func,view/id,24765/
.
Developer comment:
The goal here must be to allow the Relay Host to end up as either [relay.host]:port or relay.host:port in /etc/postfix/main.cf. The first form turns off MX lookups, the second form allows it. The port needs to default to 25 but it should be possible to override it. Currently, if you specify relay.host, it ends up as [relay.host]:25 in /etc/postfix/main.cf and there is no webconfig way of overriding the port.