1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Configure sendmail to use alternate port

Discussion in 'Installation and Maintenance of Ports or Packages' started by UncleBob, Jul 28, 2009.

  1. UncleBob

    UncleBob New Member

    Messages:
    2
    Thanks Received:
    0
    Hi, (not sure if I'm posting to the right place thou)

    I've been trying to move sendmail from 25 port to something else. I've added the following to the master config:

    DAEMON_OPTIONS(`Port=2525, Name=MTA')

    Afterwards I compiled new .cf file and restarted sendmail.

    It worked, coz when I telnet to port 2525 I can see sendmail there, but the problem is that it still listens to port 25.

    Is there any way to configure sendmail to free port 25?
     
  2. DutchDaemon

    DutchDaemon Administrator Staff Member Administrator Moderator

    Messages:
    10,725
    Thanks Received:
    2,137
    I've tried some alternatives (also involving shutting down the 'submit' side of Sendmail), but it looks like defining 'MTA' anywhere in your .mc file (even with an alternative port) will always open port 25.
     
  3. DutchDaemon

    DutchDaemon Administrator Staff Member Administrator Moderator

    Messages:
    10,725
    Thanks Received:
    2,137
    A last alternative was to omit MTA entirely and take the submit route:

    /etc/rc.conf
    Code:
    sendmail_submit_enable="YES"
    sendmail_enable="NO"


    sendmail.mc
    Code:
    FEATURE(`no_default_msa')
    DAEMON_OPTIONS(`Port=2525, Name=MSA, M=E')


    /etc/rc.d/sendmail forcestart

    Result:
    Code:
    # sockstat -4p 25      
    USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
    root     sendmail   81354 5  tcp4   *:25                  *:*
    root     sendmail   81329 3  tcp4   127.0.0.1:25          *:*
    # sockstat -4p 2525
    USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
    root     sendmail   81354 3  tcp4   *:2525                *:*


    Looks like port 25 is very much hardcoded.
     
  4. DutchDaemon

    DutchDaemon Administrator Staff Member Administrator Moderator

    Messages:
    10,725
    Thanks Received:
    2,137
    Hm, doing it straight up seems to have some result:

    /etc/rc.conf
    Code:
    sendmail_enable="YES"
    sendmail_flags="-L sm-mta -bd -q30m -ODaemonPortOptions=Port=2525"


    (nothing special in .mc)

    Code:
    # sockstat -4p 2525
    USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
    root     sendmail   81578 3  tcp4   *:2525                *:*
    # sockstat -4p 25
    USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
    root     sendmail   81329 3  tcp4   127.0.0.1:25          *:*
    


    The latter (localhost:25) is needed for handling system email anyway, but your external port 25 will be freed.

    If you really want to kill local mail handling:

    /etc/rc.conf
    Code:
    sendmail_enable="YES"
    sendmail_flags="-L sm-mta -bd -q30m -ODaemonPortOptions=Port=2525"
    sendmail_submit_enable="NO"
     
  5. UncleBob

    UncleBob New Member

    Messages:
    2
    Thanks Received:
    0
    Wow,

    Thank you for your time! I'll try this approach.

    There will be antispam proxy on external port 25, so I guess localhost:25 is fine to leave for sendmail.
     
  6. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,526
    Thanks Received:
    2,351
    In that case simply running sendmail in local-submit-only mode should do. Just have the anti-spam proxy deliver it's mail to localhost:25.

    Setting sendmail_enable="NO" in /etc/rc.conf will make sendmail run in local-submit-only mode.