Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Obviously I can't send myself an email to tell myself that qmail is not working... at least not using qmail. How would you inform yourself about the fact, that qmail is not running?

share|improve this question
up vote 3 down vote accepted

Easiest way is probably an http post or wget to a secondary server that can send the email.

Obviously if your mailbox is on this server it wont work so you would need to use another email address.

For instance, run a cron job every minute to detect if the process qmail is running. If it isn't running then wget http://secondserver/alert.php

cronjob bash script.


if ps ax | grep -v grep | grep $SERVICE > /dev/null
    echo "$SERVICE service running, everything is fine"
    echo "$SERVICE is not running"
    wget http://secondserver/alert.php



$to = '';

$subject = 'qmail not running';

$message = "qmail reported down";

$headers = "From:\r\nReply-To:";

$mail_sent = @mail( $to, $subject, $message, $headers );

echo $mail_sent ? "Mail sent" : "Mail failed";

This solution is a poor mans way of doing it but the simplest. I'd invest in a monitoring solution such as nagios. With a proper monitoring tool you can setup a solution that can sms you when down.

This is also a popular monitoring service:

share|improve this answer
thanks pablo, we're implementing this for the time being! – markus Feb 14 '11 at 9:32
for the future we definitely have to look into monitoring services. – markus Feb 14 '11 at 9:38

DJ Bernstein wrote qmail. I approve of the other answer, but I must comment:

Many people running qmail eventually bite the bullet and set up DJ Bernstein's other late jurassic period project to monitor services called daemontools. It will keep qmail working through almost anything, including zombie invasions, overheated processors and bad memory.

It works really, really well - I suspect that daemontools is the chuck norris of the daemon world. [Daemons = original name for what we now call services]

Regardless of your OS or distribution, there will be a daemon service keepalive program, and you just have to add qmail to it. We don't trust anyone or anything, so we run emails through the mail server and then check to see if they arrived within a reasonable time period. This is THE ONLY WAY to really know if it's working correctly. Monitoring a service is only 50% of a proper health check.

It's worth reading about DJB. I always assumed he was really old, but not so much.

share|improve this answer

Just to add an additional answer- you could test, from another server if the mail port is listening for mail (assuming this is open to this other server)- if it reports that it is blocked, then it could notify you of the fact.

share|improve this answer

One possible way could be to setup a monitoring service, like Nagios, and add qmail to be monitored.This way not only can you be notified about a failed qmail service, but, in fact, you can also be warned of an impending failure, so that you can take the necessary actions to prevent the failure from actually happening.

share|improve this answer

I like pablo's approach; I've used something similar to send IM-style messages tracking IP address movement of my home computer connected to work via a VPN (since it was assigned a different address every time):

import xmpp

xmpp_login  = 'user'
xmpp_domain = ''
xmpp_pwd    = 'content-purged'
xmpp_server = ''
xmpp_recp   = ''

conn = xmpp.Client(xmpp_domain)
conn.connect(server=(xmpp_server, 5222))
conn.send(xmpp.Message(xmpp_recp, "message body"))

Obviously, this requires a XMPP (Jabber) account - you can post messages 'to yourself', so one is sufficient.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.