Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
sortmail(1)		     General Commands Manual		     sortmail(1)

NAME
     sortmail - sort email messages by date/time

SYNOPSIS
     sortmail [ -chHmMyYrRvx ] mbox...

DESCRIPTION
     sortmail  is  a  front end for decomposemail(1) and recomposemail(1).  Each
     mailbox argument is disassembled into its component  messages,  then  these
     messages are reassembled into new mailboxes based on command line selection
     criteria.	 Some  additional  functionality  is  provided,  such  as backup
     copies, recursion, etc.

OPTIONS
     The following options are supported:

     -c        Move current month mailbox back to original mailbox,  implies  -r
	       (for use with -m, -M, -y, or -Y).

     -h        Help, just print an informational message, and exit.

     -H        Here, do work in the current directory instead of in ./SM_WORK.

     -m        Sort to monthly mailboxes of type mbox.YYMM.

     -M        Sort to monthly mailboxes of type YYMM/mbox.

     -y        Sort to yearly mailboxes of type mbox.YYYY.

     -Y        Sort  to  yearly  mailboxes  of type YYYY/mbox.	With -m, sort to
	       mailboxes of type YYYY/mbox.MM.	With -M, sort  to  mailboxes  of
	       type YYYY/MM/mbox.

     -r        Remove (replace) the original mailbox after sorting.

     -R        Recurse, redo any appended mailboxes (for use with -m, -M, -y, or
	       -Y).

     -v        Verbose, even more messages.

     -x        Don't make any backup copies in ./SM_BACKUP.

OPERANDS
     The following operands are supported:

     mbox      The  name (with optional path) of a standard Internet style mail-
	       box file.

USAGE
     sortmail can help to organize saved email for archival and  retrieval  pur-
     poses.   Messages	are sorted by date/time, then reassembled into new mail-
     boxes.  A notable feature is the ability  to  separate  the  messages  into
     monthly or yearly mailboxes.

     The default behavior is to take each mbox (mailbox) argument, make a backup
     copy,  make a working copy, decompose it into individual message files, and
     then recompose the messages ordered by date in increasing order.

     With the -m flag, the messages are  reassembled  into  separate  files  per
     month,  mbox.YYMM;  for  example, "mlist.9801".  With the -M flag, the mes-
     sages are reassembled into separate  files  per  month  in  subdirectories,
     YYMM/mbox;  for  example, "9801/mlist".  With the -y flag, the messages are
     reassembled  into	separate  files  per  year,  mbox.YYYY;   for	example,
     "mlist.1998".  With the -Y flag, the messages are reassembled into separate
     files per year in subdirectories, YYYY/mbox; for example, "1998/mlist".  If
     -Y  is  combined  with -m, the messages are reassembled into separate files
     per  month   in   yearly	subdirectories,   YYYY/mbox.MM;   for	example,
     "1998/mlist.01".	If  -Y is combined with -M, the messages are reassembled
     into separate  files  per	month  in  yearly  and	monthly  subdirectories,
     YYYY/MM/mbox;  for  example,  "1998/01/mlist".   In any of these cases, any
     such pre-existing mailboxes will be appended.   If  any  such  pre-existing
     mailboxes	are compressed (.Z or .gz), they will first be uncompressed, and
     then recompressed after being modified.

     With the -c flag (along with -m, -M, -y, or -Y), the mbox file for the cur-
     rent month (if any) will be renamed as the original mbox.

     With the -R flag (along with -m, -M, -y, or -Y), when a month file is  com-
     bined with one that already exists, the resulting file will be resorted.

     With  the	-H flag, all work is done in the current directory instead of in
     ./SM_WORK.  This reduces the usefulness of some of the other  options,  and
     is a bit riskier.	(Also known as "the gonzo option".)

     By  default, all work is done in a subdirectory ./SM_WORK, and all files to
     be modified are backed up in a subdirectory ./SM_BACKUP.  These subdirecto-
     ries are created if they don't already exist.  These are not cleaned up af-
     ter sorting, though none of the  temporary  message  files  or  sort  files
     should remain.

     Much  of  this  can  be  accomplished using decomposemail(1) and recompose-
     mail(1) directly, but many more manual steps are required.

EXAMPLES
     Sort the messages in the mailbox "mail/CERT", not making a backup	copy  in
     ./SM_BACKUP,  and	rename	the  new sorted mailbox to the original mailbox.
     Without -r, the new mailbox would remain in "./SM_WORK":

	  sortmail -xr mail/CERT

     Sort the messages in the mailbox "FreeBSD", separating  messages  by  month
     into  mailboxes  like  "FreeBSD.9801",  "FreeBSD.9802",  etc.  The original
     mailbox will be overwitten with any messages for the current month:

	  sortmail -mc FreeBSD

     Sort the messages in the mailboxes "maya" and "jim", separating messages by
     month  into  mailboxes  in  subdirectories  like  "9801/maya",  "9801/jim",
     "9802/maya", "9802/jim", etc.  Any such pre-existing mailboxes that are ap-
     pended will also be resorted:

	  sortmail -MR maya jim

     Sort  the messages in the mailbox "yada", separating messages by month into
     mailboxes in subdirectories like "1998/01/yada", "1998/02/yada", etc.   Any
     such  pre-existing  mailboxes  that are appended will also be resorted, and
     the original mailbox will be overwitten with any messages for  the  current
     month:

	  sortmail -YMcR yada

FILES
     ./SM_BACKUP   Directory  where sortmail makes a backup copy of each mailbox
		   before sorting it.

     ./SM_WORK	   Directory where sortmail does its  work:  makes  a  temporary
		   copy of each mbox, and a serialized file for each message.

     mbox.YYYYMMDD.hhmmss.nnnnn
		   Temporary  serialized  files for each individual message in a
		   mailbox, where "mbox" is the name of the mailbox,  "YYYYMMDD"
		   is  the  year,  month, and day, "hhmmss" is the hour, minute,
		   and second, and "nnnnn" is  a  serialization  number.   These
		   will  be  created  in  the ./SM_WORK directory, unless the -H
		   flag is specified.

DIAGNOSTICS
     Returns 0 if no problems encountered.
     Returns non-zero for any errors encountered.

BUGS
     sortmail is a shell script that uses the filesystem  for  sorting.   It  is
     slow.

     Due to copies made during the sorting process, you should have enough addi-
     tional  space  in	your  current  partition and/or quota to hold three full
     copies of each original mbox.

     sortmail is quite verbose, even without the  -v  option.	A  quiet  option
     should be added.

     Data  at  the  beginning of a mailbox that does not appear to be part of an
     email message will be silently discarded.

     sortmail creates working directories and backup copies  of  mailboxes,  and
     does not clean up after itself (except as noted above).

     sortmail relies on the scripts decomposemail(1) and recomposemail(1).  This
     is either a bug or a feature.

SEE ALSO
     compress(1), decomposemail(1), gzip(1), recomposemail(1), sh(1);
     mailsort (Perl script, available from CPAN sites);
     "Toolman:	 Sorting and Archiving Email", ;login: magazine (USENIX Associa-
     tion), August 1998;
     <http://www.cs.duke.edu/~des/sortmail.html>.

AUTHOR
     sortmail was written by Daniel E. Singer (a.k.a. Toolman) at the Department
     of Computer Science, Duke University.

Toolman 			12 September 1998		     sortmail(1)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=sortmail&sektion=1&manpath=FreeBSD+Ports+15.1.quarterly>

home | help