LinuxCommandLibrary

countmail

Count messages in mailboxes

SYNOPSIS

countmail [-d directory]

PARAMETERS

-d directory
    Specifies an alternative Maildir path to scan instead of the default $HOME/Maildir or the path specified by the MAILDIR environment variable. This allows checking mailboxes located at non-standard paths.

DESCRIPTION

The countmail command is a utility primarily designed to quickly determine and display the number of new email messages within a user's Maildir. It is not a standard, universally available core Linux command, but rather a component of specific mail system packages, most notably maildrop. A Maildir is a directory-based email format where each message is stored as a separate file. When a message is delivered to a Maildir, it initially resides in the 'new' subdirectory. Upon being viewed by a mail client, it's typically moved to the 'cur' subdirectory. countmail's function is straightforward: it simply counts the number of files present in the 'new' subdirectory of a specified Maildir. If the count is zero, it usually prints nothing; otherwise, it outputs the numeric count to standard output. This makes it ideal for integrating into scripts or status lines for immediate notification of new mail.

CAVEATS

countmail is not a part of the standard core Linux utilities; its availability depends on the installation of packages like maildrop. Behavior and specific options might vary significantly if you encounter a custom-scripted version of countmail. It strictly counts messages in the 'new' subdirectory, meaning it will not count messages in 'cur' (even if unread by a mail client) or 'tmp'. It provides no information about message content or read/unread status beyond the simple 'new'/'not new' distinction.

USAGE IN STATUS BARS AND PROMPTS

A common use case for countmail is its integration into system status bars (e.g., in window managers like i3, dwm, or bspwm) or within interactive shell prompts (e.g., in bash or zsh). By running countmail periodically, users can display the number of new emails directly in their terminal or desktop status line, providing a non-intrusive and immediate notification of incoming mail without the need to actively check a mail client.

HISTORY

The countmail utility is distributed as part of the maildrop mail delivery agent (MDA) package, developed by Sam Varshavchik. maildrop gained popularity as an alternative to traditional MDAs, especially within setups using qmail or Postfix. The inclusion of countmail addresses the practical need for a lightweight, efficient tool to check for new mail status in a Maildir environment, without requiring a full mail client to be launched or complex mailbox parsing to occur.

SEE ALSO

maildrop(1), maildir(5), mutt(1), mail(1)

Copied to clipboard