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
# sendmail.mc
define(`SMART_HOST',`relay.example.com`)dnl
If your relay server is listening on a port 587 that becomes:
# sendmail.mc
define(`SMART_HOST',`relay.example.com`)dnl
define(`RELAY_MAILER',`esmtp')dnl
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:
# sendmail.cf
# <snip>
Mesmtp587, P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
T=DNS/RFC822/SMTP,
A=TCP $h 587
Mesmtp2525, P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
T=DNS/RFC822/SMTP,
A=TCP $h 2525
transport channel 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:
example.com esmtp587:example.com
example2.com esmtp2525:example2.com
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:
example.com esmtp587:[smtp.example.com]
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.