MAIRIX(1)

πŸ“¦
version 0.24 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

mairix(1) πŸ¦‹ β€” index and search mail folders

✨ NAME ✨

mairix β€” index and search mail folders πŸ’Œ

🌸 SYNOPSIS 🌸

πŸ“‡ Indexing

mairix [ -v|--verbose ] [ -p|--purge ] [ -f|--rcfile mairixrc ] [
-F|--fast-index ] [ --force-hash-key-new-database hash ]

πŸ” Searching

mairix [ -v|--verbose ] [ -f|--rcfile mairixrc ] [ -r|--raw-output ] [
-x|--excerpt-output ] [ -H|--force-hardlinks ] [ -o|--mfolder mfolder ]
[ -a|--augment ] [ -t|--threads ] search-patterns

πŸŽ€ Other

mairix [ -h|--help ]

mairix [ -V|--version ]

mairix [ -d|--dump ]

🫢 DESCRIPTION 🫢

Okay bestie, gather round. mairix indexes and searches a whole collection of email messages, no cap. The folders that hold the messages you wanna index? They’re defined in the config file. The indexing stage spits out a database file. That database file gives you rapid access to details of the indexed messages during searching operations. A search normally produces a folder (the so-called mfolder) containing the matched messages. But there’s also a raw mode (-r) that just lists the matched messages instead. πŸ’…

It can operate with these folder types:

  • maildir
  • MH (compatible with the MH folder formats used by xmh, sylpheed, claws-mail, nnml (Gnus) and evolution)
  • mbox (including mboxes that have been compressed with gzip or bzip2)
  • IMAP: remote folders on an IMAP server

If maildir or MH source folders are used, and a search outputs its matches to an mfolder in maildir or MH format, then symbolic links are used to reference the original messages inside the mfolder. But if mbox folders are involved, copies of messages are made instead. If IMAP folders are used for both source results, then IMAP server-side copies of messages are made. With IMAP source folders and any other type of results folder, messages are downloaded from the IMAP server to be written to the results folder. With an IMAP results folder and any other type of source folders, messages are uploaded to the IMAP server to be appended to the results folder. πŸ¦‹

πŸ’– OPTIONS πŸ’–

mairix decides whether indexing or searching is required by looking for the presence of any search-patterns on the command line. It’s giving β€œread the room, then read the args.” ✨

πŸ‘‘ Special modes

  • -h, --help β€” Show usage summary and exit. πŸŽ€
  • -V, --version β€” Show program version and exit. ⭐
  • -d β€” Dump the database’s contents in human-readable form to stdout. πŸ‘‘

🌈 General options

  • -f mairixrc, --rcfile mairixrc β€” Specify an alternative configuration file to use. The default configuration file is ~/.mairixrc. πŸ’–
  • -v, --verbose β€” Make the output more verbose. πŸ—£οΈ
  • -Q, --no-integrity-checks β€” Normally mairix will do some internal integrity tests on the database. The -Q option removes these checks, making mairix run faster, but it will be less likely to detect internal problems if any bugs creep in. The nochecks directive in the rc file has the same effect. 🚨
  • --unlock β€” mairix locks its database file during any indexing or searching operation to prevent multiple indexing runs interfering with each other, or an indexing run interfering with search runs. The --unlock option removes the lockfile before doing the requested indexing or searching operation. This is a convenient way of cleaning up a stale lockfile if an earlier run crashed for some reason or was aborted. πŸ”“

πŸ“₯ Indexing options

  • -p, --purge β€” Cause stale (dead) messages to be purged from the database during an indexing run. (Normally, stale messages are left in the database because of the additional cost of compacting away the storage that they take up.) 🧹
  • -F, --fast-index β€” When processing maildir and MH folders, mairix normally compares the mtime and size of each message against the values stored in the database. If they have changed, the message will be rescanned. This check requires each message file to be stat’ed. For large numbers of messages in these folder types, this can be a sizeable overhead. This option tells mairix to assume that when a message currently on-disc has a name matching one already in the database, it should assume the message is unchanged. A later indexing run without using this option will fix up any rescans that were missed due to its use. ⚑
  • --force-hash-key-new-database hash β€” This option should only be used for debugging. If a new database is created, hash is used as hash key, instead of a random hash. πŸ›

πŸ”Ž Search options

  • -a, --augment β€” Append newly matched messages to the current mfolder instead of creating the mfolder from scratch. βž•
  • -t, --threads β€” As well as returning the matched messages, also return every message in the same thread as one of the real matches. 🧡
  • -r, --raw-output β€” Instead of creating an mfolder containing the matched messages, just show their paths on stdout. πŸ“„
  • -x, --excerpt-output β€” Instead of creating an mfolder containing the matched messages, display an excerpt from their headers on stdout. The excerpt shows To, Cc, From, Subject and Date. With IMAP source folders, this requires downloading each matched message from the IMAP server. πŸ‘€
  • -H, --force-hardlinks β€” Instead of creating symbolic links, force the use of hardlinks. This helps mailers such as alpine to realize that there are new mails in the search folder. πŸ”—
  • -o mfolder, --mfolder mfolder β€” Specify a temporary alternative path for the mfolder to use, overriding the mfolder directive in the rc file. mairix will refuse to output search results into any folder that appears to be amongst those that are indexed. This is to prevent accidental deletion of emails. πŸ›‘

πŸ” Search patterns

  • t:word β€” Match word in the To: header. πŸ’Œ
  • c:word β€” Match word in the Cc: header. πŸ“¬
  • f:word β€” Match word in the From: header. πŸ“©
  • s:word β€” Match word in the Subject: header. πŸ“
  • m:word β€” Match word in the Message-ID: header. πŸ†”
  • b:word β€” Match word in the message body. Message body is taken to mean any body part of type text/plain or text/html. For text/html, text within meta tags is ignored. In particular, the URLs inside <A HREF="..."> tags are not currently indexed. Non-text attachments are ignored. If there’s an attachment of type message/rfc822, this is parsed and the match is performed on this sub-message too. If a hit occurs, the enclosing message is treated as having a hit. πŸ“–
  • d:[start-datespec]-[end-datespec] β€” Match messages with Date: headers lying in the specific range. πŸ“…
  • z:[low-size]-[high-size] β€” Match messages whose size lies in the specified range. If the low-size argument is omitted it defaults to zero. If the high-size argument is omitted it defaults to infinite size. For example, to match messages between 10kilobytes and 20kilobytes in size, the following search term can be used:
mairix z:10k-20k

The suffix 'k' on a number means multiply by 1024, and the suffix 'M' on a number means multiply by 1024*1024. πŸ“

  • n:word β€” Match word occurring as the name of an attachment in the message. Since attachment names are usually long, this option would usually be used in the substring form. So
mairix n:mairix=

would match all messages which have attachments whose names contain the substring mairix. The attachment name is determined from the name=xxx or filename=xxx qualifiers on the Content-Type: and Content-Disposition: headers respectively. πŸ“Ž

  • F:flags β€” Match messages with particular flag settings. The available flags are 's' meaning seen, 'r' meaning replied, and 'f' meaning flagged. The flags are case-insensitive. A flag letter may be prefixed by a '-' to negate its sense. Thus
mairix F:-s d:1w-

would match any unread message less than a week old, and

mairix F:f-r d:-1m

would match any flagged message older than a month which you haven’t replied to yet. Note that the flag characters and their meanings agree with those used as the suffix letters on message filenames in maildir folders. 🚩

🧩 Searching for a match amongst more than one part of a message

Multiple body parts may be grouped together, if a match in any of them is sought. Common examples follow. 🫢

  • tc:word β€” Match word in either the To: or Cc: headers (or both). πŸ’ž
  • bs:word β€” Match word in either the Subject: header or the message body (or both). 🧠

The a: search pattern is an abbreviation for tcf:; i.e. match the word in the To:, Cc: or From: headers. ("a" stands for "address" in this case.) πŸ“‡

πŸ”€ Match words

The word argument to the search strings can take various forms. ✨

  • ~word β€” Match messages not containing the word. 🚫
  • word1,word2 β€” This matches if both the words are matched in the specified message part. 🀝
  • word1/word2 β€” This matches if either of the words are matched in the specified message part. πŸ”€
  • substring= β€” Match any word containing substring as a substring. πŸ”
  • substring=N β€” Match any word containing substring, allowing up to N errors in the match. For example, if N is 1, a single error is allowed, where an error can be:
    • a missing letter
    • an extra letter
    • a different letter. πŸ“
  • ^substring= β€” Match any word containing substring as a substring, with the requirement that substring occurs at the beginning of the matched word. 🎯

βš–οΈ Precedence matters

The binding order of the constructions is: πŸ‘‘

  1. Individual command line arguments define separate conditions which are AND-ed together. πŸ”—
  2. Within a single argument, the letters before the colon define which message parts the expression applies to. If there is no colon, the expression applies to all the headers listed earlier and the body. πŸ“¬
  3. After the colon, slashes delineate separate disjuncts, which are OR-ed together. πŸ”€
  4. Each disjunct may contain separate conjuncts, which are separated by commas. These conditions are AND-ed together. 🀝
  5. Each conjunct may start with a tilde to negate it, and may be followed by a slash to indicate a substring match, optionally followed by an integer to define the maximum number of errors allowed. 🎯

πŸ—“οΈ Date specification πŸ—“οΈ

Okay bestie, this section is the whole vibe of how you write dates when you're searching with the d: option. It's giving calendar app, but make it Unix. ✨

Dates are specified as a range. The start and the end of the range can both be specified. But if you leave the start out, it gets treated as the beginning of time. And if you leave the end out, it gets treated as the current time. Easy. 🫢

There are 4 basic formats:

  • d:start-end β€” specify both start and end explicitly. πŸ’…
  • d:start- β€” specify start, and the end is the current time.
  • d:-end β€” specify end, and the start is 'a long time ago' (i.e. early enough to include any message). πŸ‘΅
  • d:period β€” specify start and end implicitly, as the start and end of the period given.

The start and end can be specified either absolute or relative. A relative endpoint is given as a number followed by a single letter defining the scaling:

  • d β€” short for days β€” e.g. 3d β€” meaning 3 days
  • w β€” short for weeks β€” e.g. 2w β€” meaning 2 weeks (14 days)
  • m β€” short for months β€” e.g. 5m β€” meaning 5 months (150 days)
  • y β€” short for years β€” e.g. 4y β€” meaning 4 years (4*365 days)

Months are always treated as 30 days, and years as 365 days, for this purpose. No cap, that's just the rule. πŸ—“οΈ

Absolute times can be specified in many forms. Some of those forms have different meanings when they define a start date versus when they define an end date. And plot twist: where a single expression specifies both the start and the end (i.e. where the argument to d: doesn't contain a -), it will usually have different interpretations in the two cases. πŸ™ˆ

In the examples below, suppose the current date is Sunday May 18th, 2003 (when I started to write this material.)

  • d:20030301-20030425 β€” start: March 1st, 2003 Β· end: 25th April, 2003
  • d:030301-030425 β€” start: March 1st, 2003 Β· end: April 25th, 2003 β€” note: century assumed
  • d:mar1-apr25 β€” start: March 1st, 2003 Β· end: April 25th, 2003
  • d:Mar1-Apr25 β€” start: March 1st, 2003 Β· end: April 25th, 2003 β€” note: case insensitive
  • d:MAR1-APR25 β€” start: March 1st, 2003 Β· end: April 25th, 2003 β€” note: case insensitive
  • d:1mar-25apr β€” start: March 1st, 2003 Β· end: April 25th, 2003 β€” note: date and month in either order
  • d:2002 β€” start: January 1st, 2002 Β· end: December 31st, 2002 β€” note: whole year
  • d:mar β€” start: March 1st, 2003 Β· end: March 31st, 2003 β€” note: most recent March
  • d:oct β€” start: October 1st, 2002 Β· end: October 31st, 2002 β€” note: most recent October
  • d:21oct-mar β€” start: October 21st, 2002 Β· end: March 31st, 2003 β€” note: start before end
  • d:21apr-mar β€” start: April 21st, 2002 Β· end: March 31st, 2003 β€” note: start before end
  • d:21apr- β€” start: April 21st, 2003 Β· end: May 18th, 2003 β€” note: end omitted
  • d:-21apr β€” start: January 1st, 1900 Β· end: April 21st, 2003 β€” note: start omitted
  • d:6w-2w β€” start: April 6th, 2003 Β· end: May 4th, 2003 β€” note: both dates relative
  • d:21apr-1w β€” start: April 21st, 2003 Β· end: May 11th, 2003 β€” note: one date relative
  • d:21apr-2y β€” start: April 21st, 2001 Β· end: May 11th, 2001 β€” note: start before end
  • d:99-11 β€” start: January 1st, 1999 Β· end: May 11th, 2003 β€” note: 2 digits are a day of the month if possible, otherwise a year
  • d:99oct-1oct β€” start: October 1st, 1999 Β· end: October 1st, 2002 β€” note: end before now, single digit is a day of the month
  • d:99oct-01oct β€” start: October 1st, 1999 Β· end: October 31st, 2001 β€” note: 2 digits starting with zero treated as a year
  • d:oct99-oct1 β€” start: October 1st, 1999 Β· end: October 1st, 2002 β€” note: day and month in either order
  • d:oct99-oct01 β€” start: October 1st, 1999 Β· end: October 31st, 2001 β€” note: year and month in either order

The principles in the table work as follows. 🧠✨

  • When the expression defines a period of more than a day (i.e. if a month or year is specified), the earliest day in the period is taken when the start date is defined, and the last day in the period if the end of the range is being defined.
  • The end date is always taken to be on or before the current date.
  • The start date is always taken to be on or before the end date.

πŸ“ SETTING UP THE MATCH FOLDER πŸ“

If the match folder doesn't exist when you're running in search mode, it gets automatically created. Iconic, honestly. πŸŽ€

For mformat=maildir (the default), that should be literally all you need to do. But if you use mformat=mh, you may have to run some commands before your mailer will recognize the folder. e.g. for mutt, you could do:

mkdir -p /home/richard/Mail/mfolder
touch /home/richard/Mail/mfolder/.mh_sequences

which seems to work. 🫑 Alternatively, within mutt, you could set MBOX_TYPE to mh and save a message to +mfolder to have mutt set up the structure for you in advance.

If you use Sylpheed, the best way seems to be to create the new folder from within Sylpheed before letting mairix write into it. Noted. πŸ’œ


🌸 EXAMPLES 🌸

Suppose my email address is <richard@doesnt.exist>.

Either of the following will match all messages newer than 3 months from me with the word 'chrony' in the subject line:

mairix d:3m- f:richard+doesnt+exist s:chrony
mairix d:3m- f:richard@doesnt.exist s:chrony

Suppose I don't mind a few spurious matches on the address, I want a wider date range, and I suspect that some messages I replied to might have had the subject keyword spelt wrongly (let's allow up to 2 errors):

mairix d:6m- f:richard s:chrony=2

Slay. Two ways to say the exact same thing, and one fuzzy-search glow-up. πŸ”₯


πŸ“ NOTES πŸ“

mairix works exclusively in terms of words. The index that's built in indexing mode contains a table of which words occur in which messages. Hence, the search capability is based on finding messages that contain particular words. mairix defines a word as any string of alphanumeric characters + underscore. Any whitespace, punctuation, hyphens etc are treated as word boundaries. So like, word = word, and everything else is just a little fence between them. 🚧

mairix has special handling for the To:, Cc: and From: headers. Besides the normal word scan, these headers are scanned a second time, where the characters '@', '-' and '.' are also treated as word characters. This allows most (if not all) email addresses to appear in the database as single words. So if you have a mail from wibble@foobar.zzz, it will match on both these searches:

mairix f:foobar
mairix f:wibble@foobar.zzz

It should be clear by now that the searching cannot be used to find messages matching general regular expressions. This has never been much of a limitation. Most searches are for particular keywords that were in the messages, or details of the recipients, or the approximate date. fr fr, it just works. πŸ’…

It's also worth pointing out that there is no 'locality' information stored, so you can't search for messages that have one words 'close' to some other word. For every message and every word, there is a simple yes/no condition stored β€” whether the message contains the word in a particular header or in the body. So far this has proved to be adequate. mairix has a similar feel to using an Internet search engine. πŸ”βœ¨


πŸ—‚οΈ FILES πŸ—‚οΈ

  • ~/.mairixrc

πŸ‘‘ AUTHOR πŸ‘‘

Copyright (C) 2002-2006 Richard P. Curnow <rc@rc0.org.uk>


πŸ¦‹ SEE ALSO πŸ¦‹


πŸ’€ BUGS πŸ’€

We need a plugin scheme to allow more types of attachment to be scanned and indexed. That's the whole bug. Somebody go build it please. πŸ™


That's the whole page bestie, you made it to the end. πŸŽ‰

Signing off: this is the mairix(1) manual, dated January 2006, copyright vibes from 2002-2006, and it ate. Periodt. πŸŽ€πŸ’–πŸŒˆ

πŸ“¦ where this page comes from