qmail not running on port 25

Posted on 2005-04-17
Medium Priority
Last Modified: 2013-12-15
I installed qmail and it seems to be running, but nothing is listening on port 25. When I do "netstat -lntp", it doesn't show anything on port 25.

Here's the results of telnet and ps:

$ telnet localhost 25
telnet: connect to address Connection refused

$ ps -ef | grep "qmail"
qmails    9618     1  0 00:07 ?        00:00:00 qmail-send
qmaill    9619  9618  0 00:07 ?        00:00:00 splogger qmail
root      9620  9618  0 00:07 ?        00:00:00 qmail-lspawn ./Mailbox
qmailr    9621  9618  0 00:07 ?        00:00:00 qmail-rspawn
qmailq    9622  9618  0 00:07 ?        00:00:00 qmail-clean
root      9763  8022  0 00:15 pts/0    00:00:00 grep qmail

Question by:HappyEngineer
  • 7
  • 6
  • 2
  • +1

Expert Comment

ID: 13801784
Looks like you forget to run qmail-smtpd,
please read again your INSTALL file,  step number 16.


Darmawan W. Anandita

Author Comment

ID: 13804273
Actually, I installed it using the rpm command and then started it using webmin.

But, in any case, I added the following line to /etc/initd.conf:
  smtp stream tcp nowait qmaild /var/qmail/bin/tcp-env tcp-env /var/qmail/bin/qmail-smtpd

It didn't make any difference. I rebooted and now
  ps -ef | grep "qmail"
doesn't return any results.

I assume that if I went to webmin and started qmail again that it would start those processes again, but regardless it's still not working.

Expert Comment

ID: 13805134
start the qmail, qmailctl start, and then do qmailstat, u shld have

/service/qmail-send: up (pid 29956) 2 seconds
/service/qmail-send/log: up (pid 29960) 2 seconds
/service/qmail-smtpd: up (pid 29963) 2 seconds
/service/qmail-smtpd/log: up (pid 29968) 2 seconds
/service/qmail-pop3d: up (pid 29971) 2 seconds
/service/qmail-pop3d/log: up (pid 29972) 2 seconds
messages in queue: 0
messages in queue but not yet preprocessed: 0

Then do Telenet to port 25, make sure telnet is workin ;-), and check weather u have it enabled

Set up RELAY in tcp.smtp

echo '127.:allow,RELAYCLIENT=""' >> /etc/tcp.smtp

do a reload, qmailctl cdb

if this doesnt work out, plz paste the logs of qmail
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 13829445
If you're adding to inetd.conf, then netstat should show inetd as listening on port 25.  If it does not, then there's a problem with your inetd configuration.  In either case, I would not recommend running qmail from inetd.

If possible, one should run it from daemon-tools using supervise.  Durshan's example output shows supervise being used for this.

The output for ps -ef should show tcpserver running qmail-smtpd.

I'm not familiar with how webmin sets up qmail.  Please include the name, version and source of the RPM package you're using, if problems persist.

Author Comment

ID: 13831348
After typing the following message, I tried to find which rpm package I installed. I now see that it says "patch" in those names. Does that mean that those are versions of qmail with a particular patch or does that mean that all I've got on my system is some files that are part of a patch?
$rpm -q -a | grep "qmail"

Anyway, here's the rest of the message I wrote:

First off, my "uname -a" is:
  Linux knowlist.com 2.6.8-1.521smp #1 SMP Mon Aug 16 09:25:06 EDT 2004 i686 i686 i386 GNU/Linux

As for qmailctl and qmailstat, I don't have those commands.

Here's the contents of my /var/qmail/bin directory:

-rwxr-xr-x   1 root   qmail  7816 Apr 16 14:37 bouncesaying
-rwxr-xr-x   1 root   qmail 13960 Apr 16 14:37 condredirect
-rwxr-xr-x   1 root   root   2198 Apr 16 14:37 config
-rwxr-xr-x   1 root   root   1087 Apr 16 14:37 config-fast
-rwxr-xr-x   1 root   qmail   126 Apr 16 14:37 datemail
-rwxr-xr-x   1 root   root   9800 Apr 16 14:37 dnsfq
-rwxr-xr-x   1 root   root   9800 Apr 16 14:37 dnsip
-rwxr-xr-x   1 root   root   9800 Apr 16 14:37 dnsptr
-rwxr-xr-x   1 root   qmail   114 Apr 16 14:37 elq
-rwxr-xr-x   1 root   qmail  7752 Apr 16 14:37 except
-rwxr-xr-x   1 root   qmail 11848 Apr 16 14:37 forward
-rwxr-xr-x   1 root   root   3592 Apr 16 14:37 hostname
-rwxr-xr-x   1 root   root  16040 Apr 16 14:37 instcheck
-rwxr-xr-x   1 root   root   5800 Apr 16 14:37 ipmeprint
-rwxr-xr-x   1 root   qmail 15400 Apr 16 14:37 maildir2mbox
-rwxr-xr-x   1 root   qmail  7560 Apr 16 14:37 maildirmake
-rwxr-xr-x   1 root   qmail 14120 Apr 16 14:37 maildirwatch
-rwxr-xr-x   1 root   qmail   179 Apr 16 14:37 mailsubj
-rwxr-xr-x   1 root   qmail   115 Apr 16 14:37 pinq
-rwxr-xr-x   1 root   qmail 10600 Apr 16 14:37 predate
-rwxr-xr-x   1 root   qmail 10952 Apr 16 14:37 preline
-rwxr-xr-x   1 root   qmail   115 Apr 16 14:37 qail
-rwxr-xr-x   1 root   qmail  8904 Apr 16 14:37 qbiff
-rwx--x--x   1 root   qmail  7496 Apr 16 14:37 qmail-clean
-rwx--x--x   1 root   qmail  4648 Apr 16 14:37 qmail-getpw
-rwxr-xr-x   1 root   qmail 30696 Apr 16 14:37 qmail-inject
-rwx--x--x   1 root   qmail 30632 Apr 16 14:37 qmail-local
-rwx------   1 root   qmail 13992 Apr 16 14:37 qmail-lspawn
-rwx------   1 root   qmail 13896 Apr 16 14:37 qmail-newmrh
-rwx------   1 root   qmail  9800 Apr 16 14:37 qmail-newu
-rwxr-xr-x   1 root   qmail 18216 Apr 16 14:37 qmail-pop3d
-rwx--x--x   1 root   qmail  9928 Apr 16 14:37 qmail-popup
-rwx--x--x   1 root   qmail 13960 Apr 16 14:37 qmail-pw2u
-rwxr-xr-x   1 root   qmail 10120 Apr 16 14:37 qmail-qmqpc
-rwxr-xr-x   1 root   qmail 13992 Apr 16 14:37 qmail-qmqpd
-rwxr-xr-x   1 root   qmail 18120 Apr 16 14:37 qmail-qmtpd
-rwxr-xr-x   1 root   qmail 13992 Apr 16 14:37 qmail-qread
-rwxr-xr-x   1 root   qmail   371 Apr 16 14:37 qmail-qstat
-rws--x--x   1 qmailq qmail 12056 Apr 16 14:37 qmail-queue
-rwx--x--x   1 root   qmail 22344 Apr 16 14:37 qmail-remote
-rwx--x--x   1 root   qmail 13960 Apr 16 14:37 qmail-rspawn
-rwx--x--x   1 root   qmail 33544 Apr 16 14:37 qmail-send
-rwxr-xr-x   1 root   qmail 12872 Apr 16 14:37 qmail-showctl
-rwxr-xr-x   1 root   qmail 22408 Apr 16 14:37 qmail-smtpd
-rwx------   1 root   qmail  5176 Apr 16 14:37 qmail-start
-rwxr-xr-x   1 root   qmail  7656 Apr 16 14:37 qmail-tcpok
-rwxr-xr-x   1 root   qmail  9768 Apr 16 14:37 qmail-tcpto
-rwxr-xr-x   1 root   qmail 18344 Apr 16 14:37 qreceipt
-rwxr-xr-x   1 root   qmail  8840 Apr 16 14:37 qsmhook
-rwxr-xr-x   1 root   qmail  7816 Apr 16 14:37 sendmail
-rwx--x--x   1 root   qmail  5672 Apr 16 14:37 splogger
-rwxr-xr-x   1 root   qmail 14088 Apr 16 14:37 tcp-env

As far as I can tell, webmin starts it by calling

The contents of the rc file is:

  # Using splogger to send the log through syslog.
  # Using qmail-local to deliver messages to ~/Mailbox by default.

  exec env - PATH="/var/qmail/bin:$PATH" \
  qmail-start ./Mailbox splogger qmail

As for the qmail logs, I'm not sure which ones are for qmail. But, the last lines in /var/log/maillog are:
Apr 20 23:15:08 knowlist qmail: 1114064108.635126 status: local 0/10 remote 2/20
Apr 20 23:15:32 knowlist qmail: 1114064132.643260 delivery 6: deferral: Sorry,_I_wasn't_able_to_establish_an_SMTP_connection._(#4.4.1)/
Apr 20 23:15:32 knowlist qmail: 1114064132.643321 status: local 0/10 remote 1/20
Apr 20 23:15:47 knowlist qmail: 1114064147.672090 delivery 4: deferral: Sorry,_I_wasn't_able_to_establish_an_SMTP_connection._(#4.4.1)/
Apr 20 23:15:47 knowlist qmail: 1114064147.672241 status: local 0/10 remote 0/20
Apr 20 23:17:22 knowlist qmail: 1114064242.083631 status: exiting
Apr 20 23:19:45 knowlist qmail: 1114064385.037813 status: local 0/10 remote 0/20
Apr 20 23:20:21 knowlist qmail: 1114064421.356213 status: local 0/10 remote 0/20
Apr 20 23:21:29 knowlist qmail: 1114064489.195530 status: local 0/10 remote 0/20
Apr 20 23:21:47 knowlist qmail: 1114064507.818716 status: local 0/10 remote 0/20
Apr 20 23:47:40 knowlist qmail: 1114066060.399193 status: local 0/10 remote 0/20

The "status: local 0/10 remote 0/20" line gets output every time I start it from the webmin console.

Expert Comment

ID: 13831394
Hi again!

Based on your information, your q-mail smtpd isnt running yet.
the shortest way to solve your problem is, install ucspi package for your operating system.
then start the q-mail smtpd using this command:

tcpserver -u 'qmaild_uid' -g 'nofiles_gid'  0 smtp /var/qmail/bin/qmail-smtpd &


Darmawan W. Anandita

Author Comment

ID: 13831651
Well, it's getting closer. I installed a ucspi package, but when I run "tcpserver" it says:
  "Incorrectly built binary which accesses errno or h_errno directly. Needs to be fixed."

However, it still runs anyway. I ran the tcpserver command you specified and I can telnet to port 25 now. I couldn't quit it with ctrl-c, so I actually had to kill the ssh session. But, anyway, I tried using a program that sent mail and the program didn't give any error messages about not being able to access port 25 now. But, I haven't received the message it sent.

So, I'm not sure if it's my program or if the mail sending stuff still doesn't work.

Expert Comment

ID: 13836295
Very few daemons will respond to control-C on a telnet session.  In the SMTP protocol, issuing the command "QUIT" (or "quit", w/o quotes in both cases) will tell the SMTP server that you wish to end the session.  You can also use Ctrl-] to signal the standard Unix telnet client that you wish to enter control mode, and then "quit" which will indicate to your telnet client to exit the connection.

In order to give you accurate advice, it will need to be known where this qmail came from, how it's intended to be run, etc... otherwise it's a matter of shooting in the dark based on generic qmail implementations.

rpm -qi var-qmail-create qmail-1.03

That will yield the info for the two RPM packages, and will show who packaged it, the build host, and possibly a URL and other information.  var-qmail-create appears to be a package distributed at qmail.org (not the official qmail site) for the specific purpose of creating a patched qmail package.  qmail has not been updated since 1.03 by the author, and as such all new features/fixes/etc. are thru patches.  (The author, djb, refuses to consider the errno.h issue a "bug", even though it prevents qmail from being built on modern Linux systems and is a simple fix... he's an interesting guy.)

Based on the var-qmail-create readme, the package created contains patches 14 and 15, which are the errno.h declaration fix, and some fixes for qmail-local.c.  Both very small and simple issues, so it doesn't sound like this is a radically modified qmail.

The second thing to determine is the general operating environment.  Knowing what distribution of Linux you're running will help ensure that any solutions will not step on toes.  This can be determined with precision by doing:

cat /etc/*-release

This should display the contents of at least one file, showing something like "Red Hat Enterprise Linux ES release 3 (Taroon Update 4)"

Author Comment

ID: 13838813
Ok, here you go:

$ cat /etc/*-release
Fedora Core release 2 (Tettnang)
Fedora Core release 2 (Tettnang)

$ rpm -qi var-qmail-create qmail-1.03
Name        : var-qmail-create             Relocations: (not relocatable)
Version     : 1.03                              Vendor: (none)
Release     : 111patch_14_15                Build Date: Sat 16 Apr 2005 02:34:41 PM PDT
Install Date: Sat 16 Apr 2005 02:36:18 PM PDT      Build Host: knowlist.com.secureserver.net
Group       : Utilities/System              Source RPM: var-qmail-create-1.03-111patch_14_15.src.rpm
Size        : 343151                           License: Check with djb@cr.yp.to
Signature   : (none)
Packager    : mw@csi.hu
URL         : http://www.qmail.org/
Summary     : Creates binary package for qmail
Description :
This package creates a binary package for qmail.
Name        : qmail                        Relocations: (not relocatable)
Version     : 1.03                              Vendor: (none)
Release     : 111patch_14_15                Build Date: Sat 16 Apr 2005 02:37:25 PM PDT
Install Date: Sat 16 Apr 2005 02:44:08 PM PDT      Build Host: knowlist.com.secureserver.net
Group       : Utilities/System              Source RPM: qmail-1.03-111patch_14_15.src.rpm
Size        : 880453                           License: Check with djb@cr.yp.to
Signature   : (none)
Packager    : mw@csi.hu
URL         : http://cr.yp.to/qmail.html
Summary     : qmail Mail Transfer Agent
Description :
qmail is a small, fast, secure replacement for the
sendmail package, which is the program that actually receives, routes,
and delivers electronic mail.  *** Note: Be sure and read the
documentation as there are some small but very significant differences
between sendmail and qmail and the programs that interact with them.

The domain name in that info is wrong. I changed it later after installing this. The correct domain is "knowlist.com". I think I got it in all the config files.


Expert Comment

ID: 13839082
Okay, so I'm assuming that you installed qmail yourself, using the var-qmail-create package?

What ucspi package are you using?  I.e. where did you download it from?

Expert Comment

ID: 13839688
It looks like the ucspi-tcp package you're using is fairly old, and could have odd issues come up as a result, but if it works.. it works.  I'm not sure about the error about errno; it looks like the source rpm currently on contrib.redhat.com was built for redhat 9.  It may help to rebuild the source rpm there (rpmbuild --rebuild ucspi-tcp-0.88-2macchi1.src.rpm).  On a side note, the URL on rpmfind is incorrect... the correct URL is: ftp://contrib.redhat.com/pub/contrib/libc6/SRPMS/ucspi-tcp-0.88-2macchi1.src.rpm.  You may also want to try upgrading to the latest precompiled rpm on redhat's ftp with: rpm -Uv ftp://contrib.redhat.com/pub/contrib/libc6/i686/ucspi-tcp-0.88-2macchi1.i686.rpm

Usually qmail is run from "supervise"; the purpose of supervise is to start and stop software on request, to automatically restart it if required, and to handle logging (typically via splogger or multilog).  These are all 'djb' software.  I don't see any reason that you can't run it from under webmin, but you may wish to move to supervise in the future.

The standard way of running qmail from supervise is in two portions.  The first portion is for qmail delivery, which is a matter of running /var/qmail/rc; if it exits, it's restarted.

The second portion is for the qmail smtp daemon.  This uses tcpserver instead of inetd to handle the incoming connections to port 25.  Syntax should be similar to:

tcpserver -v -u qmaild -g qmail -R 0 smtp /var/qmail/bin/qmail-smtpd

If you telnet to port 25, you should be greeted by something like: 220 knowlist.com ESMTP

It may delay for up to 30 seconds or more, depending on reverse DNS lookups and the like, so if it seems to hang be patient.  If and when you've got this far, then additional tweaking can be done, etc.

Please note that typically tcpserver is used in conjunction with a tcprules file (database) that contains a list of IP addresses to accept connections from.  This way, you can send e-mail via SMTP connections, both from localhost and from approved remote hosts.  This is often used in conjunction with POP3 authentication, to permit roaming relays.  tcpserver will pass the "authorized or not" information to qmail-smtpd, which will then either allow mail to be sent or not; if the requested destination host is in /var/qmail/control/rcpthosts or /var/qmail/control/morercpthosts, then the mail will accepted regardless.

Author Comment

ID: 13841020
I ran:
   rpm -Uv ftp://contrib.redhat.com/pub/contrib/libc6/i686/ucspi-tcp-0.88-2macchi1.i686.rpm
and now tcpserver runs without any error messages. Great!

But, mail is stil disappearing. First off, even though I thought I had the domain name set correctly, if I telnet to 25 it says:

$ telnet localhost 25
tcpserver: status: 1/40
Connected to localhost.
Escape character is '^]'.
tcpserver: pid 20212 from
tcpserver: ok 20212 localhost: localhost:
220 ip-216-69-165-36.ip.secureserver.net ESMTP

Why does it still think I'm "ip-216-69-165-36.ip.secureserver.net"? I don't know where it's getting that info.

Next, I try sending to a local user and the mail seems to go through. But, it never shows up in a local mailbox accessable using the "mail" command. I don't need local delivery, but I just want to do it to make sure it works.

I checked /var/log/maillog and it has a bunch of messages like:

Apr 22 01:14:55 knowlist qmail: 1114157695.212469 end msg 6604669
Apr 22 01:16:29 knowlist qmail: 1114157789.197741 starting delivery 11: msg 6604633 to remote knowlist@g42.org
Apr 22 01:16:29 knowlist qmail: 1114157789.197812 status: local 0/10 remote 1/20
Apr 22 01:16:29 knowlist qmail: 1114157789.202470 delivery 11: deferral: Sorry,_I_wasn't_able_to_establish_an_SMTP_connection._(#4.4.1)/
Apr 22 01:16:29 knowlist qmail: 1114157789.202533 status: local 0/10 remote 0/20
Apr 22 01:19:15 knowlist qmail: 1114157955.177869 starting delivery 12: msg 6604625 to remote abcabc@g42.org
Apr 22 01:19:15 knowlist qmail: 1114157955.177931 status: local 0/10 remote 1/20
Apr 22 01:19:15 knowlist qmail: 1114157955.316971 delivery 12: deferral: Sorry,_I_wasn't_able_to_establish_an_SMTP_connection._(#4.4.1)/
Apr 22 01:19:15 knowlist qmail: 1114157955.317043 status: local 0/10 remote 0/20
Apr 22 01:19:39 knowlist qmail: 1114157979.574722 alert: cannot start: qmail-send is already running

Lastly, I think outgoing mail may be failing because godaddy blocks outgoing mail on port 25. I found the following:
  "I eventually figured out that they problem is my host (GoDaddy). They block a whole bunch of ports, including outgoing port 25 (SMTP) which the can't/won't turn off. I had to relay my mail through their server using QMail's smtproutes control file. They really should display this somewhere on their site."

Sorry to drag this question on so long. I can start another one if you like (there's no way to tip points in experts-exchange *smile*).

Accepted Solution

macker- earned 2000 total points
ID: 13845803
qmail sets all the hostnames in a control file, rather than reading them dynamically.  the var-qmail-create script probably did a reverse dns lookup on your local IP, then placed this in /var/qmail/control/me

The GoDaddy issue does indeed sound like that's the problem for outgoing e-mail.  You can resolve this with the smtproutes file, to add an entry to deliver all (remote) e-mail thru GoDaddy's mail server.  I'd highly recommend looking at qmail.org and lifewithqmail.org (LWQ); both are excellent resources that go a bit further than the sometimes cryptic djb documentation.

Based on the output you're showing from tcpserver, it sounds like it is starting up correctly and running.  Now here's the more challenging part..  qmail-smtpd has no useful logging.  It is virtually impossible to directly correlate smtpd logs with local delivery.  The good news is that most qmail problems can be figured out by banging your head against the desk for a few minutes, looking at it again, and realizing what is out of place.  Some problems can be recognized based on the cryptic error, a matter of "oh, that usually means ..."

When qmail-smtpd receives a message, the message is in turn injected into the queue.  If it cannot receive the message into the queue, it will reject the e-mail.  If it can, then it's in the queue.

Now, once the message is in the queue, it's the responsibility of qmail-send to process the queue, identify messages that need to be delivered, and have qmail-lspawn/qmail-local deliver the messages (or qmail-rspawn/qmail-remote for outgoing messages).

Now the way I'd recommend troubleshooting this is to shut down the qmail-send side but leave the SMTP side running, and send a message to a "local" recepient.  /var/qmail/bin/qmail-qstat should show 0 unprocessed messages prior to this, and 1 unprocessed messages following.  Once you start up the qmail delivery side, you should see qmail-qstat showing 0 unprocessed messages again.  At this point, you should either see a message for "local" delivery in the maillog, or you should see the message in the queue (/var/qmail/bin/qmail-qread).

Also, to backtrack for a moment... most distributions, RedHat included, use mbox format by default.  This means mail is spooled up in one single file in /var/spool/mail/username, and some mail clients will create a matching file in ~/Mail/.  qmail, on the other hand, uses the Maildir format.  This creates one file for each message, and places them in a single directory in the user's home directory.  This is two very different methods, and arguments over which offers better performance aside, your mail client must support the format you're using.  "pine" uses mbox by default, but can be patched to use Maildir.  Most people use POP3 or IMAP to access e-mail these days, so the important factor is to have a Maildir-compatible daemon.  The Courier-IMAP package provides Maildir POP3 and IMAP daemons, and qmail includes a POP3 daemon.  vpopmail is also commonly used in conjunction with qmail to provide virtual domain support.  There is a multitude of options relating to virtual domains, and this really is a topic in itself.

Your system may already be configured for qmail-pop3 but not Maildir-compatible command-line readers... try "telnet localhost pop3" or "telnet localhost 110".  It should prompt you with something like "+OK Hello there.".  Send the text "USER username", response "+OK Password required.", send "PASS password", and you should get "+OK logged in.".  Then send the "LIST" command, which should yield a list of pairs of numbers; the first number is a message number, and this side of the list is sequential.  The second number is the size of the message, in bytes.  Once you've confirmed that there are (or are not) any messages, "QUIT" will close the session.

Author Comment

ID: 13855609
A person responded to that thread indicating that adding
to the smtproutes file.

I did that and restarted it using webmin and it works! Hooray!

For the past couple hours the server has been sending me old cron messages. Apparently all the pent up mail is not sent simultaneously.

Anyway, it works now! Thank you so much for all your help!

I'll look into "supervise". I haven't got my stuff set up to work after reboot, so supervise looks like the way to go.

Expert Comment

ID: 13855682
qmail processes messages sequentially, and delivers messages in a queue system.  For each delivery, it uses one of the concurrency slots.  By default, up to 10 simultaneous local deliveries will occur.  You can check on the status in the logs; local 0/10 means 0 out of 10 deliveries still active at the time the log message is written, and remote 0/20 would mean there are 0 out of 20 maximum simultaneous deliveries in progress.

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question