Apr 15

Due to the increase in the number of ISP’s blocking port 25 for third party mailservers I decided to setup my mailserver to answer SMTP request on multiple ports. While this can be accomplished in many ways, such as port forwarding or multiple instances of qmail-smtpd, my situation required setting up a second instance or qmail-smtpd.

The setup process is fairly straight forward. Here are the steps I took to accomplish my goal:

First you will need to stop qmail and make a copy of your qmail-smtpd directory located in /var/qmail/supervise/smtp. I called my new copy /var/qmail/supervise/smtp2. Once the copy had been completed I then needed to edit the run file located in the smtp2 directory. This was a simple change to add the port number I wished to have qmail-smtpd run on. Here is an example:


/usr/local/bin/tcpserver -H -v -R -l “$LOCAL” -x /etc/tcp.smtp.cdb -c “$MAXSMTPD” -u “$QMAILDUID” -g “$NOFILESGID” 0 smtp \


/usr/local/bin/tcpserver -H -v -R -l “$LOCAL” -x /etc/tcp.smtp.cdb -c “$MAXSMTPD” -u “$QMAILDUID” -g “$NOFILESGID” 0 2525 \


Notice the 2525 which is the second port I will be running. Please be aware that this line may be different depending on your installation of QMail. My installation was based on the Life with Qmail instructions and also the addition of SpamAssassin, SpamHaus RBL, relay-ctrl-chk and ClamAV.

With this change complete I needed to update the run file located in the /var/qmail/supervise/smtp2/log directory. I just changed the logging path to log to a second log named smtp2.

Start qmail.

verify:  “netstat -natp|grep tcpserver” and you should see:

tcp        0      0        *                   LISTEN      31692/tcpserver
tcp        0      0      *                   LISTEN      31735/tcpserver


written by MG \\ tags: , , ,

8 Responses to “Running Toaster QMail SMTP on a 2nd port”

  1. 1. Lucas Jokiel Says:

    Or, to spare resources you could use port translation. To make your box full RFC compliant:

    iptables -t nat -A PREROUTING -p tcp -m tcp –dport 465 -j REDIRECT –to-ports 25
    iptables -t nat -A PREROUTING -p tcp -m tcp –dport 587 -j REDIRECT –to-ports 25
    iptables -t nat -A OUTPUT -p tcp -m tcp –dport 465 -j REDIRECT –to-ports 25
    iptables -t nat -A OUTPUT -p tcp -m tcp –dport 587 -j REDIRECT –to-ports 25

  2. 2. MG Says:

    Yes.. But if you use NAT you may have problems with conntrack table. I only load module iptables_nat when is strictly necessary.

  3. 3. аватары Says:

    he used the same technique in the end and it worked

  4. 4. Missy Says:


    I tried this and for some reason when I start qmail back up, it doesn’t find my second smtp server. I tried running the run file, but that just says it’s listening if I do a netstat. If I try to connect to port 2525, I get no response. Let me know if you have any ideas!


  5. 5. MG Says:

    Missy : maybe you are doing something wrong.

  6. 6. snasfu Says:

    Have you checked, that you port is open in your firewall?

  7. 7. Frank Says:


    I have a question: what are all qmail ports? except 25 and 2525

  8. 8. Paul Says:

    Your a bloody star!

Leave a Reply