Search Engine: Elastic

Article ID: 121187, created on Apr 18, 2014, last review on Apr 16, 2015

  • Applies to:
  • Operations Automation


Messages not sent, not delivered, throttle limits

Problems with sending:

  1. Check if server can inject new messages into sending queue:

    # telnet <server_IP> 25

    If connection can be established, try to authorize and send a message to any external address.

    NOTE: authorization details are checked against LDAP, the credentials to access it are located in /usr/local/qmail/shared/control/ldap_settings

    If connection cannot be established, check that qmail service is running and port 25 is being listened on:

    # netstat -ntpl | grep :25

    NOTE smtp service binding is configured in xinetd:

    # cat /etc/xinetd.d/qmail 
    service smtp
    disable = no
    socket_type = stream
    protocol = tcp
    wait = no
    user = qmaild
    group = qmail
    server = /usr/local/qmail/bin/tcp-env
    server_args = /usr/local/qmail/bin/qmail-smtpd /usr/local/qmail/bin/cmd5checkpw
    cps = 0 0
  2. If the messages are injected into mail queue, check 2 things:

    • Mail queue, using qmail-stat:

      # /usr/local/qmail/bin/qmail-qstat 
      messages in queue: 37
      messages in queue but not yet preprocessed: 0

      If queue has too many messages (>1-2K) - most probably, it is overloaded. If it is - please see the section Removing various types of messages from queue.

      Use /usr/local/qmail/bin/qmail-qread to see the human-readable information about outgoing emails.

    • Log, check the maillog for errors.
  3. Removing various types of messages from queue:

    • If queue is full of spam, you can try to clear it using the following script:

      TS=`date +%d.%m.%Y.%s`
      find /usr/local/qmail/queue/mess/ -type f -exec grep -lEi '<word1>|<word2>|...|<wordN>' {} \; >> /tmp/76K_q.${TS}
      /etc/rc.d/init.d/qmail stop
      sleep 5
      cat /tmp/76K_q.${TS} | while read fn
      short_fn=`echo ${fn} | sed 's#^.*/##'`
      rm -f -- /usr/local/qmail/queue/bounce/${short_fn} /usr/local/qmail/queue/intd/${short_fn} /usr/local/qmail/queue/todo/${short_fn}
      rm -f -- ${fn}
      echo ${fn} | sed "s/mess/local/g" | xargs rm -f --
      echo ${fn} | sed "s/mess/remote/g" | xargs rm -f --
      echo ${fn} | sed "s/mess/info/g" | xargs rm -f --
      echo ${fn} | sed "s/mess/todo/g" | xargs rm -f --
      j=$[$j+1] ; if [ $j -eq 500 ] ; then i=$[$i+500]; j=0; echo $i ${fn} ; fi ;
      /etc/rc.d/init.d/qmail start

      Please replace '<word1>|<word2>|...|<wordN>' with words that appear in spam messages.

      NOTE: this script completely stops qmail service, removes the messages and starts the service

    • If you want to remove bounce messages, you can use the following commands:

      # /etc/rc.d/init.d/qmail stop
      # cd /usr/local/qmail/queue/
      # for F in `ls bounce/`;do find ./ -name "$F" -exec rm {} \; ;done
      # /etc/rc.d/init.d/qmail start
    • To clear the whole queue:

      # /etc/rc.d/init.d/qmail stop
      # cd /usr/local/qmail/queue/
      # find . -type f -exec rm {} \;
      # /etc/rc.d/init.d/qmail start
    • Using qmHandle utility:

      qmail service should be stopped while working with qmHandle. Usage of qmHandle:

      • delete all messages from queue

        # qmHandle -D
      • delete messages number:

        # qmHandle -dN
      • delete all messages containing the <text> as subject:

        # qmHandle -S<text>
      • delete all messages containing the <text> as From:

        # qmHandle -F<text>
      • delete all messages containing the <text> as TO:

        # qmHandle -T<text>
  4. Issues with throttle limits.

    LDAP stores the throttle settings for each account. They can be acquired using following query:

    # ldapsearch -LLL -x -D 'cn=admin,dc=pem,dc=swsoft,dc=com' -b 'dc=pem,dc=swsoft,dc=com' -h -w'ldap_passwd' "(mailname=user@domain.tld)"
    dn: mailname=user@domain.tld,ou=mail,dc=pem,dc=swsoft,dc=com
    objectClass: mailname
    mailname: user@domain.tld
    homedir: /usr/local/qmail/shared/mailnames/g/c/-4/4/
    login: user@domain.tld
    password: $1$ZY9iRsUN$Km6chU8jtVuTvJGSSsKB1.
    passwordType: encrypted
    servedBy: qmail01
    throttlingPerDay: 1000
    throttlingPerHour: 100
    throttlingPerMinute: 100
    trafficConsumerID: 1
    trafficConsumerTypeID: 0
    trafficRTIID: 241849
    throttlingPerDay: 1000
    throttlingPerHour: 100
    throttlingPerMinute: 100

Courier and dovecot

To retrieve messages either courier-imap or dovecot is used. They run on port 143 and may be checked through telnet as well:

# telnet <server_IP> 143 

These services also use LDAP for authentication, the issues are most likely connected to NFS share that stores the mailboxes, for example:

# telnet <server_hostname> 143
Trying <IP>...
Connected to  <server_hostname> (<IP>).
Escape character is '^]'.

OK [CAPABILITY IMAP4rev1 NAMESPACE QUOTA ACL UIDPLUS CHILDREN IDLE] Courier-IMAP ready. Copyright 1998-2008 Double Precision, Inc. See COPYING for distribution information.

a1 login customer@domain.tld password

BYE Temporary problem, please try again later
Connection closed by foreign host.

It is caused by missing mailbox dir on qmail server. According to ldap info:

homedir: /usr/local/qmail/shared/mailnames/j/d/domain.tld/customer/

Whereas this dir is empty:

# ll /usr/local/qmail/shared/mailnames/j/d/domain.tld/customer/
total 0

This can be caused by unmounted NFS partition(can be checked through mount) or by mailbox having been removed (due to terminated subscription e.g.).

Known issues

LDAP server

LDAP runs on a separate node, and usually its availability can be checked by a query from qmail server:

# ldapsearch -LLL -x -D 'cn=admin,dc=pem,dc=swsoft,dc=com' -b 'dc=pem,dc=swsoft,dc=com' -h -w'ldap_passwd' "(mailname=customer@domain.tld)"

If LDAP is not responding - try to rebuild and reindex DB like in KB #113851

Performance problems

In case qmail servers are overloaded, check the following first:

  1. Disable traffic shaping if qmail servers are VPSes. Do the following on hardware node:

    # grep -A 4 TRAFFIC_SHAPING /etc/sysconfig/vz
    # /etc/init.d/vz shaperoff
  2. Increase qmail concurrent settings limits:

    # cat /usr/local/qmail/shared/control/concurrencylocal
    # cat /usr/local/qmail/shared/control/concurrencyremote

    First limit is the maximum number of simultaneous local delivery attempts, the second is maximum number of simultaneous remote delivery attempts

  3. Check trigger file permissions as in KB#122711

  4. Monitor overall mail servers metrics: connections, smtps, impap, messages in queue, system load:

    echo "Hostname(qmailcls1) `hostname`"
    echo "Average Load: `cat /proc/loadavg`"
    #echo "Process with Disk I/O: `iotop -oPbn 1|wc -l`"
    echo "`iostat | grep -A2 iowait`"
    echo "Established SMTP connections(.16): `netstat -tnp | grep :25 | grep -i esta|wc -l`"
    echo "Total SMTP connections(.16): `netstat -tnp | grep :25 |wc -l`"
    echo "Established POP3 connections(.16): `netstat -tnp | grep :110 | grep -i esta|wc -l`"
    echo "Established IMAP connections(.16): `netstat -tnp | grep :143 | grep -i esta|wc -l`"
    tail /var/log/maillog | grep "status: local"
  5. Tune courier-imap:

    Options MAXPERIP and maxprocs can be changed in /etc/init.d/courier-imapd for 143/993 ports.

    Also it is possible to increase the amount of auth daemons in

    # grep ^daemons /etc/authlib/authdaemonrc

Webmail problems

In case it is possible to log in using telnet utility, however, not possible to log in through webmail, the investigation should be continued on this side.

Horde configuration file is located in /usr/local/pem/sysvhosts/webmail/webmail/<ID>/config/conf.php on the corresponding webmail node. It can be edited to enable debug logging as per KB #114066

OpenXchange configuration:

The mysql DB connection settings are located in /opt/open-xchange/etc/

The information about users can be acquired through selects in DB by context id, which can be gathered from tasks' parameters.

OX log can be located in /var/log/open-xchange/.

In case you are using courier-auth, see KB #116961 for details on how to enable debug logging for this service.

Known issues

Qmail load balancer issues

Qmail balancer is an iptables solution that balances TCP packets to qmail servers using NAT table:

# iptables -Ln -t nat
target prot opt source destination
DNAT tcp -- multiport dports 25,110,143,587,993,995 to:<IP>-

target prot opt source destination
SNAT all -- <IP>/28 to:<IP>

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

To ensure that packets are passed through NAT, check that tcp packets counter is increasing:

# iptables -Lvn -t nat


SpamAssassin is configured through POA DB

plesk=> \dt sa_*
                  List of relations
 Schema |            Name            | Type  | Owner 
 public | sa_allowed_ips             | table | plesk
 public | sa_email_pattern_exclusion | table | plesk
 public | sa_email_patterns          | table | plesk
 public | sa_mail_services           | table | plesk
 public | sa_mailboxes               | table | plesk
 public | sa_services                | table | plesk

POA checks if spamassassin is configured for a mailbox by checking this table by mailname id:

plesk=> select mailbox_id,service_id,mail_filter_id,rt_instance_id from sa_mailboxes limit 10;
 mailbox_id | service_id | mail_filter_id | rt_instance_id 
      34581 |        195 |          27617 |         352799
      42513 |        195 |          34051 |         468842
      42646 |        195 |          34159 |         470267
       2761 |         19 |           2274 |          30279

And the corresponding filters can be found in table cqmail_filters:

plesk=> select * from cqmail_filters  limit 5;;
 filter_id | mailname_id |               cmd               | alters_message | priority 
        20 |          46 | spamc_wrapper_19 db/hb/46 f d   |              0 |        3
     26384 |       33053 | spamc_wrapper_19 j/v/33053 f m  |              1 |        1
     22978 |       28123 | spamc_wrapper_19 n/q/28123 f m  |              1 |        1
      1243 |        1554 | spamc_wrapper_19 kb/eb/1554 l m |              1 |        1

The exact wrappers are also written in .qmail files, which are the files that describe the actions necessary to perform for this account. If the spam filter is enabled, it should include line that begins with spamc_wrapper.

# cat /usr/local/qmail/shared/mailnames/db/db/-36396/36396/.qmail

|spamc_wrapper_19 w/tb/36396 f d

In this example qmail uses /usr/local/qmail/bin/spamc_wrapper_19 script for processing messages. See KB 116264 for additional details.

See also

5356b422f65bdad1c3e9edca5d74a1ae caea8340e2d186a540518d08602aa065 e12cea1d47a3125d335d68e6d4e15e07

Email subscription for changes to this article
Save as PDF