Qmail notes

From Noah.org
Revision as of 15:02, 30 April 2008 by Root (talk | contribs)
Jump to navigationJump to search

This is for a Qmailrocks install. This may not work on other qmail installations. Or it may work. Or it may screw up up your mail queue; or your qmail installation; or your whole machine; or your friend's machines. That is the beauty of qmail.

qmail.sh

This is the missing mail control script. It's crude, but it works. Note that this won't fix queue problems. Look for the qfixq script.

Note the "spamon" and "spamoff" commands. These are useful for turning just spam/virus filtering off. Sometimes spamassassin or clamav get messed up and it is preferable to get mail back online without spam/virus filtering while you try to figure out the problem.

#! /bin/sh
# Start or stop all mail services.
# Intended for a standard Qmail Rocks installation.
# Noah

case $1 in
status)
    echo "=== clamav ================================================="
    #/etc/init.d/clamd status
    ps auxww | grep clamd | grep -v "grep clamd"
    echo "=== spamassassin ==========================================="
    #/etc/init.d/spamd status
    ps auxww | grep spamd | grep -v "grep spamd"
    echo "=== imap ==================================================="
    ps auxww | grep imap | grep -v "grep imap"
    echo "=== authdaemond ============================================"
    # Wish I could do "/usr/local/sbin/authdaemond status"
    ps auxww | grep authdaemond | grep -v "grep authdaemond"
    echo "=== readproctitle =========================================="
    ps auxww | grep readproctitle | grep -v "grep readproctitle"
    echo "=== qmailctl ==============================================="
    /usr/bin/qmailctl stat
    echo "=== /var/log/maillog ======================================="
    tail /var/log/maillog
    echo "=== /var/log/qmail/qmail-send/current ======================"
    tail /var/log/qmail/qmail-send/current
    echo "=== /var/log/qmail/qmail-smtpd/current ====================="
    tail /var/log/qmail/qmail-smtpd/current
    echo "============================================================"
    ;;
spamon)
    cp /var/qmail/supervise/qmail-smtpd/run /var/qmail/supervise/qmail-smtpd/run.backup
    sed -i -e "s/^#QMAILQUEUE=.*/QMAILQUEUE=\"\/var\/qmail\/bin\/qmail-scanner-queue.pl\" ; export QMAILQUEUE/g" /var/qmail/supervise/qmail-smtpd/run
    ;;
spamoff)
    cp /var/qmail/supervise/qmail-smtpd/run /var/qmail/supervise/qmail-smtpd/run.backup
    sed -i -e "s/^QMAILQUEUE=.*/#QMAILQUEUE=\"\/var\/qmail\/bin\/qmail-scanner-queue.pl\" ; export QMAILQUEUE/g" /var/qmail/supervise/qmail-smtpd/run
    ;;
start)
    # Without this clamd won't start up sometimes
    # (clamd.log ownership gets messed up).
    #    ERROR: Problem with internal logger. Please check the permissions on the /var/log/clamav/clamd.log file.
    # I'm not sure what causes this, but this hack fixes it and
    # is probably harmless on systems that don't have this problem.
    chown `grep ^User /etc/clamd.conf | cut -d ' ' -f2` /var/log/clamav/*
    /usr/local/sbin/authdaemond start
    /etc/init.d/clamd start
    /etc/init.d/spamd start
    /etc/init.d/imap start
    /etc/init.d/imaps start
    svc -u /service/qmail-pop3d
    svc -u /service/qmail-smtpd
    svc -u /service/qmail-send
    /usr/bin/qmailctl start
    ;;
stop)
    /usr/bin/qmailctl stop
    svc -d /service/qmail-send
    svc -d /service/qmail-smtpd
    svc -d /service/qmail-pop3d
    /etc/init.d/imaps stop
    /etc/init.d/imap stop
    /etc/init.d/spamd stop
    /etc/init.d/clamd stop
    /usr/local/sbin/authdaemond stop
    ;;
lsq)
    find /var/qmail/queue -type f -exec ls -l {} \;
    ;;
*)
    cat <<HELPHERE
$0 COMMAND
status --- Show status of all mail services.
spamon  -- Enable spam/virus filtering in /var/qmail/supervise/qmail-smtpd/run.
spamoff -- Disable spam/virus filtering.
start ---- Start all mail services.
stop ----- Stop al mail services.
lsq ------ List all files in qmail queue folders.
HELPHERE
    ;;
esac
exit 0

Shell command aliases

Add this to your bash aliases.

alias lsq='find /var/qmail/queue -type f -exec ls -l {} \;'

User Aliases

Why isn't this documented properly? Maybe this is still an experimental command. At any rate, I had to try both way just to figure out which comes first in the argument list. This creates a new addres, alias_user@example.com. All mail sent to alias_user@example.com will get put in the mailbox for real_user@example.com.

/home/vpopmail/bin/valias -i real_user@example.com alias_user@example.com

alert: cannot start: unable to open mutex

Looking at the log file, /var/log/qmail/qmail-send/current, shows lots of "alert: cannot start: unable to open mutex" error messages. I don't know how this happened. I had shutdown qmail. Maybe I had done a hard reboot of the machine. I don't remember. Oh, good grief! Why don't I stop complaining and ditch qmail? No amount of "perfection" is worth the hassle of this thing. Only autistic savants could love qmail. At any rate, this fixed the problem (Yeah, this is obvious, right?):

qmailctl stop
touch /var/qmail/queue/lock/sendmutex
chown qmails:qmail /var/qmail/queue/lock/sendmutex
qmailctl start