GNU Mailutils Manual (split by section):   Section:   Chapter:FastBack: Programs   Up: Programs   FastForward: Libraries   Contents: Table of ContentsIndex: Function Index

3.8 readmsg — Extract Messages from a Folder

The readmsg utility extracts messages from a mailbox according to the criteria specified in the command line. These criteria are:

  1. A lone ‘*’ means “select all messages in the mailbox”.
  2. A list of message numbers may be specified. Values of ‘0’ and ‘$’ in the list both mean the last message in the mailbox. For example:
    readmsg 1 3 0
    

    extracts three messages from the folder: the first, the third, and the last.

  3. Finally, the selection may be some text to match. This will select a mail message which exactly matches the specified text. For example,
    readmsg staff meeting
    

    extracts the message which contains the words ‘staff meeting’. Note that it will not match a message containing ‘Staff Meeting’ – the matching is case sensitive by default. This can changed using the -i (--ignorecase) option. Two more options are provided to control the matching algorithm: the -g (--glob) option instructs readmsg to treat arguments as shell globbing patterns and the -r (--regex) option instructs it to treat them as POSIX extended regular expressions. Needless to say, when using any of the two latter options, you should pay attention to escape the matching pattern to prevent it from being interpreted by the shell. E.g.:

    readmsg --regex 'staff.*meeting'
    

Unless requested otherwise, only the first message that matches the pattern is printed.

At least one command line argument or one informational option must be present in readmsg invocation. Informational options are: --help (-?), --usage, and --version (-V).

3.8.1 Invocation of readmsg.

-a
--show-all

If a pattern is used for selection, show all messages that match pattern by default only the first one is presented.

-d
--debug

Display mailbox debugging information.

-e
--exact

Look for messages containing exactly the words given as arguments. This is the default. Other options changing this behavior are: --glob, --regex, and --ignorecase.

-f mailbox
--folder=mailbox

Specified the default mailbox.

-g
--glob

Treat non-option arguments as shell globbing patterns. For example, to select the first message with words ‘morning’ and ‘coffee’ with anything bewteen them:

readmsg --glob 'morning*coffee'

(notice quoting, which prevents the shell from interpreting the ‘*’ prematurely).

-h
--header

Show the entire header and ignore the weedlist.

-i
--ignorecase

Ignore the case of letters when looking for matching messages. E.g.:

readmsg --glob --ignorecase 'morning*coffee'
-n
--no-header

Do not print the message header.

-p
--form-feed

Put form-feed (Control-L) between messages instead of newline.

-r
--regex

Treat non-option arguments as POSIX extended regular expressions.

-w weedlist
--weedlist=weedlist

A whitespace or coma separated list of header names to show per message. Default is --weedlist="From Subject Date To CC Apparently-".

See also Common Options.

3.8.2 Configuration of readmsg.

Following configuration statements affect the behavior of readmsg:

Readmsg Conf: header bool

If bool is ‘true’, display entire headers.

Readmsg Conf: weedlist str

Set the weedlist. The str argument is a string, containing a list of header names, separated by whitespace, commands or colons. This corresponds to the --weedlist command line option (see –weedlist).

Readmsg Conf: no-header bool

If bool is ‘true’, exclude all headers.

Readmsg Conf: form-feeds bool

If bool is ‘true’, output formfeed character between messages.

Readmsg Conf: folder url

Set the URL of the mailbox folder to read.

Readmsg Conf: show-all-match bool

If bool is ‘true’, print all messages matching pattern, not only the first.

StatementReference
debugSee Debug Statement.
tlsSee TLS Statement.
mailboxSee Mailbox Statement.
lockingSee Locking Statement.

GNU Mailutils Manual (split by section):   Section:   Chapter:FastBack: Programs   Up: readmsg   FastForward: Libraries   Contents: Table of ContentsIndex: Function Index