LinuxCommandLibrary

from

Display messages from specific senders

TLDR

List mail

$ from
copy

Display the number of messages stored
$ from --count
copy

List mail in the specified mailbox directory
$ MAIL=[path/to/mailbox] from
copy

Print the mail from the specified address
$ from --sender=[me@example.com]
copy

SYNOPSIS

from [-s sender] [-c] [-a] [file]

PARAMETERS

-s sender
    Filters the output to only show messages sent by the specified sender.

-c
    Instead of listing individual messages, prints only the total number of messages. If a sender is specified with -s, it counts messages from that specific sender; otherwise, it counts all messages in the mailbox.

-a
    Instructs from to print the "Author" field from the 'From ' line. This field is considered very obscure and was primarily used in older ARPANET environments.

file
    Specifies an alternative mailbox file to check. If this argument is omitted, the command defaults to checking the user's primary system mailbox (e.g., /var/spool/mail/user).

DESCRIPTION

The from command is a classic Unix utility designed to inspect mailboxes and extract information about the origin of mail messages. It functions by parsing mail headers, specifically seeking out the 'From ' (note the trailing space) lines that mark the beginning of each message in traditional mail spool files. These lines typically encapsulate crucial details such as the sender's name and the exact date and time the message was sent. By default, from examines the current user's primary system mailbox, commonly found at /var/spool/mail/user on most Linux systems. However, its versatility allows users to specify an alternative mailbox file as an argument, enabling inspection of other users' mailboxes or archived mail folders. This command is fundamentally tied to the legacy mbox format, where mail messages are concatenated into a single file, making it a valuable tool for interacting with such mail storage methods in a command-line environment.

CAVEATS

The from command is not very effective for mailboxes in mbox format if they have been compacted or processed in a way that removes the specific 'From ' header line delimiters. Such mailboxes will not yield accurate results. Additionally, the use of the -a option is for a very obscure and rarely seen mail header field.

EXIT STATUS

The from command provides standard exit codes to indicate its operational outcome:

  • 0: Success – The command executed without errors.
  • 1: Failure – An error occurred, such as the specified file not being found or unreadable.
  • 2: Syntax Error – The command was invoked with incorrect arguments or options.

MAILBOX FORMAT DEPENDENCY

The core functionality of from relies heavily on the specific 'From ' line (with a trailing space) that traditionally marks the beginning of a new message in mbox format mailboxes. Without this precise header line, which acts as a separator and contains key sender information, the command cannot correctly parse or display message details. This dependency explains why compacted or non-standard mailboxes may not yield expected results when used with from.

HISTORY

The from command originates from early Unix systems, serving as a simple utility to check mail status in a command-line environment. Its design is intrinsically linked to the traditional mbox mail spool format, which stores mail messages in a single file, delimited by 'From ' lines. While its direct utility has diminished with the widespread adoption of modern mail protocols (like IMAP and POP3) and webmail interfaces, it remains a part of standard Unix/Linux distributions, often bundled with mail processing utilities like mailx or procmail. It represents a piece of historical functionality for local mail management.

SEE ALSO

mail(1), mailx(1), mbox(5), procmail(1)

Copied to clipboard