How do I run qmail on port 587?

yukon

Valued Member
One of my users can not send out smtp port 25.

How do I set up my qmail server so that it is also listening on another port such as 587?
 

EQ Admin

EQ Forum Admin
Staff member
Hi Yukon,

This is not too hard to do. You'll need to make a quick update to your qmail install and possibly allow the additional port on your server or hardware based firewall. If you are running a server that resembles a Life with qmail install here are the steps to duplicate your port 25 config over to port 587.

  • Duplicate your $supervise/qmail-smtpd into $supervise/qmail-smtp587
Pick a name that makes sense. In my case I call it qmail-smtpd-auth. Substitute your name for my name in the following steps.
  • Update the run file so tcpserver is listening on port 587 in $supervise/qmail-smtp587/run
/usr/local/bin/tcpserver -v -H -R -l "$LOCAL" -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 587 /export/qmail/bin/qmail-smtpd

  • Make a link from /service to the new folder. Mine looks like this:
lrwxrwxrwx 1 root root 13 Sep 15 2008 dnscache -> /etc/dnscache
lrwxrwxrwx 1 root root 31 Sep 15 2008 qmail-send -> /var/qmail/supervise/qmail-send
lrwxrwxrwx 1 root root 32 Sep 15 2008 qmail-smtpd -> /var/qmail/supervise/qmail-smtpd
lrwxrwxrwx 1 root root 37 Oct 20 2008 qmail-smtpd-auth -> /var/qmail/supervise/qmail-smtpd-auth
  • Last you will need to update your qmailctl script.
 

yukon

Valued Member
I did mine pretty much the same way, however the one thing that wasn't mentioned is you *should* go and add your new / second smtpd service into your qmailctl file so you can control it with the rest of the your QMail daemons.... I never really found this step mentioned anywhere online, but I inferred it's need from the LWQ site.

in my case I simply grabbed the qmail-smtpd lines, copied and edited them:

[akneppar@mail1 ~]$ sudo cat /var/qmail/bin/qmailctl
Password:
#!/bin/sh

# description: the qmail MTA

PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH

QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`

case "$1" in
start)
echo "Starting qmail"
if svok /service/qmail-send ; then
svc -u /service/qmail-send /service/qmail-send/log
else
echo "qmail-send supervise not running"
fi
if svok /service/qmail-pop3d ; then
svc -u /service/qmail-pop3d /service/qmail-pop3d/log
else
echo "qmail-pop3d supervise not running"
fi
if svok /service/qmail-smtpd ; then
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
else
echo "qmail-smtpd supervise not running"
fi
if svok /service/qmail-smtpd2 ; then
svc -u /service/qmail-smtpd2 /service/qmail-smtpd2/log
else
echo "qmail-smtpd2 supervise not running"
fi

if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/qmail
fi
;;
stop)
echo "Stopping qmail..."
echo " qmail-pop3d"
svc -d /service/qmail-pop3d /service/qmail-pop3d/log
echo " qmail-smtpd"
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo " qmail-smtpd2"
svc -d /service/qmail-smtpd2 /service/qmail-smtpd2/log
echo " qmail-send"
svc -d /service/qmail-send /service/qmail-send/log
if [ -f /var/lock/subsys/qmail ]; then
rm /var/lock/subsys/qmail
fi
;;
stat)
svstat /service/qmail-send
svstat /service/qmail-send/log
svstat /service/qmail-smtpd
svstat /service/qmail-smtpd/log
svstat /service/qmail-smtpd2
svstat /service/qmail-smtpd2/log
qmail-qstat
;;
doqueue|alrm|flush)
echo "Flushing timeout table and sending ALRM signal to qmail-send."
/var/qmail/bin/qmail-tcpok
svc -a /service/qmail-send
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
echo "Sending HUP signal to qmail-send."
svc -h /service/qmail-send
;;
pause)
echo "Pausing qmail-send"
svc -p /service/qmail-send
echo "Pausing qmail-smtpd"
svc -p /service/qmail-smtpd
echo "Pausing qmail-smtpd2"
svc -p /service/qmail-smtpd2
;;
cont)
echo "Continuing qmail-send"
svc -c /service/qmail-send
echo "Continuing qmail-smtpd"
svc -c /service/qmail-smtpd
echo "Continuing qmail-smtpd2"
svc -c /service/qmail-smtpd2
;;
restart)
echo "Restarting qmail:"
echo "* Stopping qmail-pop3d."
svc -d /service/qmail-pop3d /service/qmail-pop3d/log
echo "* Stopping qmail-smtpd."
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo "* Stopping qmail-smtpd2."
svc -d /service/qmail-smtpd2 /service/qmail-smtpd2/log
echo "* Sending qmail-send SIGTERM and restarting."
svc -t /service/qmail-send /service/qmail-send/log
echo "* Restarting qmail-smtpd."
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
echo "* Restarting qmail-smtpd2."
svc -u /service/qmail-smtpd2 /service/qmail-smtpd2/log
echo "* Restarting qmail-pop3d."
svc -u /service/qmail-pop3d /service/qmail-pop3d/log
;;
cdb)
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
chmod 644 /etc/tcp.smtp.cdb
echo "Reloaded /etc/tcp.smtp."
;;
help)
cat <<HELP
stop -- stops mail service (smtp connections refused, nothing goes out)
start -- starts mail service (smtp connection accepted, mail can go out)
pause -- temporarily stops mail service (connections accepted, nothing leaves)
cont -- continues paused mail service
stat -- displays status of mail service
cdb -- rebuild the tcpserver cdb file for smtp
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
reload -- sends qmail-send HUP, rereading locals and virtualdomains
queue -- shows status of queue
alrm -- same as doqueue
flush -- same as doqueue
hup -- same as reload
HELP
;;
*)
echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
exit 1
;;
esac

exit 0


You will note, I was not nearly as creative as you in my naming, I simply called mine "qmail-smtpd2"

another nice tidbit we should mention is to verify you are listening on your new port:
[akneppar@mail1 ~]$ sudo netstat -natp|grep tcpserver
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 28833/tcpserver
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 28840/tcpserver
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 28830/tcpserver
 
Top