Enable SMTP Port 587 on Exim
Most of the ISP block port 25 for outgoing SMTP. To enable Port 587 on exim, add this configuration to Exim’s configuration file.
daemon_smtp_ports = 25 : 587
Alternatively, with latest exim configuration file, uncomment the line below and you might want to remove 465.
# daemon_smtp_ports = 25 : 465 : 587
After that, save your configuration and restart exim service.
Test on Port 587
After exim service has restarted, make a telnet test to port 587
shell> telnet localhost 587
Connected? If yes, it means Exim on SMTP Port 587 is enabled now.
This only enables INcoming connections to Exim on port 587.
How to force Exim to use port 587, instead of port 25, when Exim itself needs to connect to another smtp server?
IT seems that most people do not want to answer this question (perhaps because they do not know the answer) and go into a long diatribe of whataboutery and their arguments about why you should not even attempt to do this.
After much searching I found the answer on the “nerwbies” site and on checking the official Exim4 documentation confirmed hat the answer provided was correct. The problem with the Exim4 documetnation is that you have to know at least part of the answer before you have some hope of finding the full answer in the relevant section where it is buried with hundreds of other options.
So in order to set the outgoing port for Exim4 to talk to another mail transport agent, the appropriate TRANSPORT has to be used and configured.
This TRANSPORT will use the SMTP drtiver. The SMTP driver by default uses port 25 of course, but the port directive can be used to chage from the default.
Obviously in the earlier ROUTER section of the configuration you will filter the messages which need to go to the remote mail transport agent on the desired port with your choice of transport name “label” eg “delivery_to_remote_mta” or something more specific if you wish. Also note that it is in the ROUTER section where you specify the remote mail transport agent host name (or IP, but not the connection port to use) in the route_list directive.
So putting that altogether
transport delivery_to_remote_mta
driver = smtp
port = 487
Other directives can be supplied to lookup authentication password if required, remove local header lines if you wish, retwrite header fields if required (so that addresses used are not local ones but are valid for Internet use and if the remote mail transport agent enforces them, uses addersses with the remote transport agent domain name (an anti-spam measure by some ISPs).
The appropriate chapter is the official Exim4 documentation is
Chapter 30 – The smtp transport
(sometimes the chapter number changes when the exim4 version changes because of more sections being added earlier in the manual)
Note that smtp is not the actual “label” name of the transport but the transport type, determined by which driver the transport uses.