Unless explicitly configured otherwise, mail will be transmitted over port 25.
You can route mail using other ports, or even other protocols than SMTP but that will typically only work within your own network. The mailservers from your intended recipients will most likely only accept incoming email via SMTP on port 25.
For instance when I configure sendmail to listen to port 587 it will typically only accept incoming e-mail over that port when the user has authenticated.
DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')
Most networks that restrict incoming and/or outgoing SMTP traffic (a good and common practice for both consumer ISP's and corporate networks to prevent open mailrelays, spam and other abuse) provide relay servers, allowing you to send mail, but not unrestricted. Relay servers may check content (viruses, spam) or enforce policies (adding the standard disclaimer, archiving messages for compliance, restricting recipients) etc.
If you're provided with a relay server; in sendmail that is called a smarthost and configured in
If your relay server is listening on a port 587 that becomes:
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
The assumption is that sendmail forwards all your email traffic to the relay which transports the messages to the intended recipients and the relay server not requiring authentication.
You can fine tune your email routing with the mailertable.
To route some email domains to one remote TCP port and mail for other domains to another requires some editing in the sendmail.cf to set up a new mailer. Copy the settings from the existing esmtp mailer and add a port number:
Mesmtp587, P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
A=TCP $h 587
Mesmtp2525, P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
A=TCP $h 2525
esmtp587 will now deliver to port 587 instead of the default 25 or and similarly to 2525 or whatever alternative port you specify.
Then in your mailertable:
The line above will allow sendmail to look up the MX records for example.com, if only a single (relay) smtp server for example.com supports the non-default port the syntax will become:
The brackets tell sendmail to ignore possible MX records for smtp.example.com and to route all mail for @example.com to smtp.example.com:587.