I have been using sendmail to send out mails using internally available mail server. But currently port 25 is blocked for security reasons. I would like to know if there is a way to specify port number in the sendmail utility. I am trying to make use of the secure SMTP-MSA port 587 as an alternative assuming I could get that port opened up. I was not able to find anything in the man pages for sendmail. Is there any alternate utility that could do this?
Using port 587 with sendmail
linux;sendmail;smtp;mail transport agent
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.mcdefine(`SMART_HOST',`relay.example.com`)dnlIf your relay server is listening on a port 587 that becomes:# sendmail.mcdefine(`SMART_HOST',`relay.example.com`)dnldefine(`RELAY_MAILER',`esmtp')dnldefine(`RELAY_MAILER_ARGS', `TCP $h 587')dnlThe 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 2525transport 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.comThe 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.