[27162] in Source-Commits
/svn/athena r25985 - in trunk/athena/bin/mitmailutils: . bin debian debian/source man
daemon@ATHENA.MIT.EDU (Victor Vasiliev)
Sun May 12 02:24:53 2013
Date: Sun, 12 May 2013 02:24:45 -0400
From: Victor Vasiliev <vasilvv@MIT.EDU>
Message-Id: <201305120624.r4C6OjFo029474@drugstore.mit.edu>
To: source-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Author: vasilvv
Date: 2013-05-12 02:24:44 -0400 (Sun, 12 May 2013)
New Revision: 25985
Added:
trunk/athena/bin/mitmailutils/bin/
trunk/athena/bin/mitmailutils/bin/from
trunk/athena/bin/mitmailutils/bin/mailquota
trunk/athena/bin/mitmailutils/bin/mailusage
trunk/athena/bin/mitmailutils/bin/mitmailappend
trunk/athena/bin/mitmailutils/bin/mitmailcreate
trunk/athena/bin/mitmailutils/bin/mitmaildel
trunk/athena/bin/mitmailutils/bin/mitmailexp
trunk/athena/bin/mitmailutils/bin/mitmailmove
trunk/athena/bin/mitmailutils/bin/mitmailrename
trunk/athena/bin/mitmailutils/bin/mitmailscan
trunk/athena/bin/mitmailutils/bin/mitmailshow
trunk/athena/bin/mitmailutils/debian/source/
trunk/athena/bin/mitmailutils/debian/source/format
trunk/athena/bin/mitmailutils/man/
trunk/athena/bin/mitmailutils/man/from.1
trunk/athena/bin/mitmailutils/man/mailquota.1
trunk/athena/bin/mitmailutils/man/mailusage.1
trunk/athena/bin/mitmailutils/man/mitmailappend.1
trunk/athena/bin/mitmailutils/man/mitmailcreate.1
trunk/athena/bin/mitmailutils/man/mitmaildel.1
trunk/athena/bin/mitmailutils/man/mitmailexp.1
trunk/athena/bin/mitmailutils/man/mitmailmove.1
trunk/athena/bin/mitmailutils/man/mitmailrename.1
trunk/athena/bin/mitmailutils/man/mitmailscan.1
trunk/athena/bin/mitmailutils/man/mitmailshow.1
Removed:
trunk/athena/bin/mitmailutils/Makefile.in
trunk/athena/bin/mitmailutils/configure.in
trunk/athena/bin/mitmailutils/from.1
trunk/athena/bin/mitmailutils/from.pl
trunk/athena/bin/mitmailutils/mailquota.1
trunk/athena/bin/mitmailutils/mailquota.pl
trunk/athena/bin/mitmailutils/mailusage.1
trunk/athena/bin/mitmailutils/mailusage.pl
trunk/athena/bin/mitmailutils/mitmailappend.1
trunk/athena/bin/mitmailutils/mitmailappend.pl
trunk/athena/bin/mitmailutils/mitmailcreate.1
trunk/athena/bin/mitmailutils/mitmailcreate.pl
trunk/athena/bin/mitmailutils/mitmaildel.1
trunk/athena/bin/mitmailutils/mitmaildel.pl
trunk/athena/bin/mitmailutils/mitmailexp.1
trunk/athena/bin/mitmailutils/mitmailexp.pl
trunk/athena/bin/mitmailutils/mitmailmove.1
trunk/athena/bin/mitmailutils/mitmailmove.pl
trunk/athena/bin/mitmailutils/mitmailrename.1
trunk/athena/bin/mitmailutils/mitmailrename.pl
trunk/athena/bin/mitmailutils/mitmailscan.1
trunk/athena/bin/mitmailutils/mitmailscan.pl
trunk/athena/bin/mitmailutils/mitmailshow.1
trunk/athena/bin/mitmailutils/mitmailshow.pl
Modified:
trunk/athena/bin/mitmailutils/debian/changelog
trunk/athena/bin/mitmailutils/debian/control
trunk/athena/bin/mitmailutils/debian/rules
Log:
In mitmailutils:
* Use debhelper7
* Create bin/ and man/ directories for organization purposes
* Bump upstream version
* Switch to source format 3.0 (quilt)
Copied: trunk/athena/bin/mitmailutils/bin/from (from rev 25984, trunk/athena/bin/mitmailutils/from.pl)
===================================================================
--- trunk/athena/bin/mitmailutils/bin/from (rev 0)
+++ trunk/athena/bin/mitmailutils/bin/from 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,346 @@
+#!/usr/bin/perl -w
+
+# $Id: from.pl,v 1.6 2004-07-29 19:11:51 rbasch Exp $
+
+# This is an implementation of the Athena "from" utility using the
+# Perl interface to the Cyrus imclient IMAP library.
+
+use strict;
+use warnings FATAL => 'all';
+use Cyrus::IMAP;
+use Getopt::Std;
+
+sub usage(;$);
+sub send_command($);
+sub search_callback(@);
+sub fetch_callback(@);
+sub number_callback(@);
+sub make_msgspecs(@);
+sub close_connection();
+sub get_localmail();
+sub get_terminal_width();
+sub errorout($);
+
+sub usage(;$) {
+ print STDERR "from: $_[0]\n" if $_[0];
+ print STDERR <<EOF;
+Usage: from [<options>] [<user>]
+ Options:
+ -N check only NEW messages in IMAP mailbox (default is UNSEEN)
+ -A check all messages in IMAP mailbox
+ -m <mailbox> check <mailbox> (default is INBOX)
+ -h <host> query <host> instead of default post office server
+ -s <sender> show mail from <sender> only
+ -n be silent when there is no mail
+ -r include Subject header
+ -v include To, Date, and Subject headers
+ -t display message totals only
+ -p check post office server only
+ -u check local mail only
+ -d turn on debugging
+EOF
+ exit 1;
+}
+
+# By default, we search for UNSEEN messages. If the user specifies -N,
+# we search for NEW messages (NEW is equivalent to "UNSEEN RECENT").
+# If -A is given, we check ALL messages.
+my $search_key = "unseen";
+
+# Parse the command line arguments.
+my %opts;
+getopts('Adh:m:Nnprs:tuv', \%opts) || usage;
+my $have_user = 0;
+my $username = shift @ARGV;
+if ($username) {
+ $have_user = 1;
+} else {
+ $username = $ENV{"ATHENA_USER"} || $ENV{'USER'} || getlogin || (getpwuid($<))[0] ||
+ errorout "Cannot determine user name";
+}
+usage "Too many arguments" if @ARGV > 0;
+my $checkall = $opts{'A'} && ($search_key = "all");
+my $debug = $opts{'d'};
+my $host = $opts{'h'} || (gethostbyname("$username.mail.mit.edu"))[0];
+errorout "Cannot find Post Office server for $username" unless $host;
+errorout "Exchange accounts are not supported yet. Try http://owa.mit.edu/." if $host =~ /EXCHANGE/;
+my $mbox = $opts{'m'} || "INBOX";
+my $quiet = $opts{'n'};
+my $checknew = $opts{'N'} && ($search_key = "new");
+my $imaponly = $opts{'p'};
+my $report = $opts{'r'};
+my $sender = $opts{'s'};
+my $totals_only = $opts{'t'};
+my $localonly = $opts{'u'};
+my $verbose = $opts{'v'};
+usage "Cannot specify both -A and -N" if $checkall && $checknew;
+usage "Cannot specify both -p and -u" if $imaponly && $localonly;
+usage "Cannot specify both -r and -t" if $report && $totals_only;
+usage "Cannot specify both -t and -v" if $totals_only && $verbose;
+
+# Check local mail first.
+my $localcount = 0;
+$localcount = get_localmail() unless $imaponly;
+
+exit 0 if $localonly;
+
+# Check mail on the IMAP server.
+# Connect to the server, and authenticate.
+my $client = Cyrus::IMAP->new($host) ||
+ errorout "Cannot connect to IMAP server on $host";
+unless ($client->authenticate(-authz => $username, -maxssf => 0)) {
+ close_connection();
+ errorout "Cannot authenticate to $host";
+}
+
+# Examine the mailbox. This gives the numbers of existing and recent
+# messages, as well as selecting the mailbox for read-only access.
+my $recentmsgcount = -1;
+my $totalmsgcount = -1;
+my @msgids = ();
+my @pomsgs = ();
+my $cb_numbered = Cyrus::IMAP::CALLBACK_NUMBERED;
+$client->addcallback({-trigger => 'EXISTS', -flags => $cb_numbered,
+ -callback => \&number_callback,
+ -rock => \$totalmsgcount});
+$client->addcallback({-trigger => 'RECENT', -flags => $cb_numbered,
+ -callback => \&number_callback,
+ -rock => \$recentmsgcount});
+send_command "EXAMINE \"$mbox\"";
+
+if ($totalmsgcount && !($checknew && !$recentmsgcount)) {
+ # Search the mailbox to obtain the message UID's.
+ $client->addcallback({-trigger => 'SEARCH',
+ -callback => \&search_callback,
+ -rock => \@msgids});
+ send_command "UID SEARCH $search_key" . ($sender ? " FROM $sender" : "");
+
+ # If there are messages of interest, fetch their size, and any desired
+ # headers.
+ if (@msgids > 0) {
+ my $fetch = "RFC822.SIZE";
+ $fetch .= " BODY.PEEK[HEADER.FIELDS (FROM TO SUBJECT DATE)]"
+ unless $totals_only;
+ $client->addcallback({-trigger => 'FETCH', -flags => $cb_numbered,
+ -callback => \&fetch_callback,
+ -rock => \@pomsgs});
+ foreach (make_msgspecs(@msgids)) {
+ send_command "UID FETCH $_ ($fetch)";
+ }
+ }
+}
+my $msgcount = @pomsgs;
+
+# We are done talking to the IMAP server, close down the connection.
+close_connection();
+
+my $msg;
+
+# Print out the summary line if appropriate.
+if (($verbose || $totals_only) && ($msgcount > 0 || !$quiet)) {
+ my $totalsize = 0;
+ for $msg (@pomsgs) {
+ $totalsize += $msg->{size};
+ }
+
+ print $have_user ? "$username has " : "You have ";
+ if ($msgcount > 0) {
+ print "$msgcount " .
+ ($checkall ? "total" : $search_key) . " message" .
+ ($msgcount > 1 ? 's' : '') .
+ " ($totalsize bytes)" .
+ ($checkall ? "" : ", $totalmsgcount total,");
+ } else {
+ print "no" .
+ ($checkall || $totalmsgcount == 0 ? "" : " $search_key") .
+ " messages";
+ }
+ print " in $mbox on $host" .
+ ($verbose && $msgcount > 0 ? ':' : '.') . "\n";
+}
+
+# Show the desired headers if appropriate.
+if (!$totals_only && $msgcount > 0) {
+ my $subject_width;
+
+ print ucfirst(($checkall ? "" : "$search_key ") .
+ "mail in IMAP folder $mbox:\n") unless $verbose || $imaponly;
+ if ($report) {
+ my $tty_width = get_terminal_width();
+ $subject_width = ($tty_width > 33 ? $tty_width - 33 : 0);
+ }
+ for $msg (@pomsgs) {
+ if ($report) {
+ printf("%-30.30s ", $msg->{from});
+ print substr($msg->{subject}, 0, $subject_width)
+ if $msg->{subject} && $subject_width;
+ print "\n";
+ } else {
+ if ($verbose) {
+ print "\n";
+ print "To: $msg->{to}\n" if $msg->{to};
+ print "Subject: $msg->{subject}\n" if $msg->{subject};
+ print "Date: $msg->{date}\n" if $msg->{date};
+ }
+ print "From: $msg->{from}\n";
+ }
+ }
+}
+
+# Subroutine to send a command to the IMAP server, and wait for the
+# response; any defined callbacks for the response are invoked.
+# If the server response indicates failure, we error out.
+sub send_command($) {
+ print "Sending: $_[0]\n" if $debug;
+ my ($status, $text) = $client->send('', '', $_[0]);
+ print "Response: status $status, text $text\n" if $debug;
+ errorout "Premature end-of-file on IMAP connection to $host"
+ if $status eq 'EOF';
+ if ($status ne 'OK') {
+ close_connection();
+ errorout "IMAP error for $mbox on $host: $text"
+ }
+}
+
+# Callback subroutine to parse the response from a SEARCH command.
+# The "-text" hash element contains the returned message UIDs,
+# separated by a space. The "-rock" element is a reference to the
+# array in which to store the UIDs.
+sub search_callback(@) {
+ my %cb = @_;
+ print "In SEARCH callback: text $cb{-text}\n" if $debug;
+ @{$cb{-rock}} = split(/\s/, $cb{-text});
+}
+
+# Callback subroutine to parse the response from a FETCH command.
+# This callback will be invoked for each message. The "-text" hash
+# element contains the text returned by the server. The "-rock"
+# element is a reference to the array in which to push a hash of the
+# various message data items.
+sub fetch_callback(@) {
+ my %cb = @_;
+ my ($from, $to, $subject, $date) = '';
+ my $size = 0;
+ print "In FETCH callback: text $cb{-text}\n" if $debug;
+ for (split /\r\n/, $cb{-text}) {
+ $size = $1 if /RFC822.SIZE\s+(\d+)/io;
+ $from = $_ if s/^From:\s*//io;
+ $to = $_ if s/^To:\s*//io;
+ $subject = $_ if s/^Subject:\s*//io;
+ $date = $_ if s/^Date:\s*//io;
+
+ }
+ push @{$cb{-rock}}, {from => $from, to => $to, subject => $subject,
+ date => $date, size => $size};
+}
+
+# Callback subroutine to parse a numeric value. The "-rock" hash
+# element is a reference to the scalar in which to store the number.
+sub number_callback(@) {
+ my %cb = @_;
+ print "In number callback: keyword $cb{-keyword}, number $cb{-msgno}\n"
+ if $debug;
+ ${$cb{-rock}} = $cb{-msgno};
+}
+
+# This subroutine takes a list of IMAP message UID numbers, and constructs
+# single-string representations of the set, collapsing sequences into
+# ranges where possible. In order to avoid constructing a specification
+# which is too long to be processed, the result is returned as an array
+# of manageably-sized specification strings, currently limited to about
+# 200 characters each.
+sub make_msgspecs(@) {
+ return '' if @_ == 0;
+ my @specs = ();
+ my $first = shift(@_);
+ my $last = $first;
+ my $spec = $first;
+ foreach (@_) {
+ if ($_ != $last + 1) {
+ # This UID is not in sequence with the previous element.
+ # If that marks the end of a range, complete it.
+ $spec .= ":$last" if ($first != $last);
+ # Begin a new sequence. Create another spec string if the
+ # current one is getting long.
+ if (length($spec) > 200) {
+ push @specs, $spec;
+ $spec = $_;
+ } else {
+ $spec .= ",$_";
+ }
+ $first = $_;
+ }
+ $last = $_;
+ }
+ # Complete the final range if necessary.
+ $spec .= ":$last" if ($first != $last);
+ push @specs, $spec if ($spec);
+ return @specs;
+}
+
+# Logout from the IMAP server, and close the connection.
+sub close_connection() {
+ $client->send('', '', "LOGOUT");
+ # Set the client reference to undef, so that perl invokes the
+ # destructor, which closes the connection. Note that if we invoke
+ # the destructor explicitly here, then perl will still invoke it
+ # again when the program exits, thus touching memory which has
+ # already been freed.
+ $client = undef;
+}
+
+# Get mail from the local ("Unix") mail drop.
+# Returns the number of messages found.
+sub get_localmail() {
+ my $maildrop = $ENV{'MAILDROP'} || "/var/spool/mail/$username";
+ # Open the mail drop.
+ unless (open MAIL, $maildrop) {
+ errorout "Cannot open maildrop $maildrop" if $localonly;
+ return 0;
+ }
+ my $count = 0;
+ my $from = '';
+ while (<MAIL>) {
+ chop;
+ if ($_ eq '' && $from) {
+ print "$from\n" unless $totals_only;
+ $count++;
+ $from = '';
+ }
+ elsif (/^From\s+([^\s\t]*)/o) {
+ next if $sender && $1 !~ /$sender/io;
+ print "Local mail:\n"
+ unless ($count > 0 || $totals_only || $localonly);
+ $from = $_;
+ }
+ }
+ if ($from) {
+ print "$from\n" unless $totals_only;
+ $count++;
+ }
+ if ($totals_only && $count) {
+ my $size = -s MAIL;
+ print $have_user ? "$username has" : "You have";
+ print " $count local messages ($size bytes).\n";
+ }
+ close(MAIL);
+ return $count;
+}
+
+sub get_terminal_width() {
+ my $columns = 80;
+ open STTY, "stty -a |" or return $columns;
+ while (<STTY>) {
+ if (/columns[\s=]+(\d+);/o) {
+ $columns = $1;
+ last;
+ }
+ }
+ close STTY;
+ return $columns;
+}
+
+sub errorout($) {
+ print STDERR "from: $_[0]\n";
+ exit 1;
+}
Copied: trunk/athena/bin/mitmailutils/bin/mailquota (from rev 25984, trunk/athena/bin/mitmailutils/mailquota.pl)
===================================================================
--- trunk/athena/bin/mitmailutils/bin/mailquota (rev 0)
+++ trunk/athena/bin/mitmailutils/bin/mailquota 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,224 @@
+#!/usr/bin/perl -w
+
+# $Id: mailquota.pl,v 1.4 2004-07-29 19:11:52 rbasch Exp $
+
+# Display the IMAP resource usage on the user's post office server.
+
+use strict;
+use warnings FATAL => 'all';
+use Cyrus::IMAP;
+use Getopt::Std;
+
+sub usage(;$);
+sub print_quota($$$$$);
+sub send_command($);
+sub quota_callback(@);
+sub quotaroot_callback(@);
+sub capability_callback(@);
+sub close_and_errorout($);
+sub close_connection();
+sub errorout($);
+
+sub usage(;$) {
+ print STDERR "mailquota: $_[0]\n" if $_[0];
+ print STDERR <<EOF;
+Usage: mailquota [<options>] [<user>]
+ Options:
+ -h <host> query <host> instead of default post office server
+ -m <mailbox> query for <mailbox> (default is INBOX)
+ -n be silent unless usage % is above the threshold
+ -u <percent> usage % threshold (default is 90); implies -n
+ -d turn on debugging
+EOF
+ exit 1;
+}
+
+my $need_header = 1;
+my $root_width = 16;
+my $num_width = 10;
+my $percent_width = 5;
+my $format = "%-${root_width}.${root_width}s" .
+ " %${num_width}s %${num_width}s %${percent_width}s" .
+ " %${num_width}s %${num_width}s %${percent_width}s\n";
+
+# Parse the command line arguments.
+my %opts;
+getopts('dh:m:nu:', \%opts) || usage;
+my $username = shift @ARGV || $ENV{'ATHENA_USER'} || $ENV{'USER'} || getlogin || (getpwuid($<))[0] ||
+ errorout "Cannot determine user name";
+
+usage "Too many arguments" if @ARGV > 0;
+my $debug = $opts{'d'};
+my $warn_only = $opts{'n'};
+my $usage_threshold = $opts{'u'};
+my $host = $opts{'h'} || (gethostbyname("$username.mail.mit.edu"))[0];
+errorout "Cannot find Post Office server for $username" unless $host;
+errorout "Exchange accounts are not supported yet. Try http://owa.mit.edu/." if $host =~ /EXCHANGE/;
+my $mbox = $opts{'m'} || "INBOX";
+
+# Validate the usage percentage threshold, allowing a trailing %.
+# Setting the threshold implies we should only display quotas
+# for which any resource usage is above the threshold.
+if (defined $usage_threshold) {
+ chop $usage_threshold if $usage_threshold =~ /^\d+%$/;
+ usage "-u argument must be numeric" if $usage_threshold !~ /^\d+$/;
+ $warn_only = 1;
+} else {
+ $usage_threshold = 90;
+}
+
+# Connect to the IMAP server, check for the QUOTA extension, and
+# authenticate.
+my $client = Cyrus::IMAP->new($host) ||
+ errorout "Cannot connect to IMAP server on $host";
+my $caps = '';
+$client->addcallback({-trigger => 'CAPABILITY',
+ -callback => \&capability_callback,
+ -rock => \$caps});
+send_command "CAPABILITY";
+$caps =~ '\bQUOTA\b' ||
+ close_and_errorout "$host does not support the IMAP QUOTA extension";
+$client->authenticate(-authz => $username, -maxssf => 0) ||
+ close_and_errorout "Cannot authenticate to $host";
+
+# Send the GETQUOTAROOT command, which returns both the QUOTA and
+# QUOTAROOT responses. Quota information will be displayed via
+# the QUOTA callback.
+$client->addcallback({-trigger => 'QUOTA',
+ -callback => \"a_callback});
+$client->addcallback({-trigger => 'QUOTAROOT',
+ -callback => \"aroot_callback});
+send_command "GETQUOTAROOT \"$mbox\"";
+
+# We are done talking to the IMAP server; close down the connection.
+close_connection();
+
+# Print the quota information for the given quota root and its
+# storage and message resource values.
+sub print_quota($$$$$) {
+ my ($root, $storage_used, $storage_max, $message_used, $message_max) = @_;
+ my $storage_percent;
+ my $storage_percent_out;
+ my $message_percent;
+ my $message_percent_out;
+
+ # Calculate the usage percentages, and format for output.
+ if ($storage_max) {
+ $storage_percent = ($storage_used / $storage_max) * 100;
+ $storage_percent_out = sprintf("%.0f%%", $storage_percent);
+ }
+ if ($message_max) {
+ $message_percent = ($message_used / $message_max) * 100;
+ $message_percent_out = sprintf("%.0f%%", $message_percent);
+ }
+
+ # Skip this quota if we are only displaying usages above the
+ # specified threshold.
+ return unless (!$warn_only ||
+ (defined $storage_percent &&
+ $storage_percent >= $usage_threshold) ||
+ (defined $message_percent &&
+ $message_percent >= $usage_threshold));
+
+ # Print a header if this is the first line of output.
+ if ($need_header) {
+ print "** IMAP e-mail usage for $mbox on $host:\n";
+ printf($format,
+ "Quota",
+ "KB Used", "KB Max", "KB %",
+ "# Msgs", "# Max", "# %");
+ $need_header = 0;
+ }
+ printf($format,
+ $root,
+ defined $storage_used ? $storage_used : '-',
+ defined $storage_max ? $storage_max : '-',
+ defined $storage_percent_out ? $storage_percent_out : '-',
+ defined $message_used ? $message_used : '-',
+ defined $message_max ? $message_max : '-',
+ defined $message_percent_out ? $message_percent_out : '-');
+}
+
+# Subroutine to send a command to the IMAP server, and wait for the
+# response; any defined callbacks for the response are invoked.
+# If the server response indicates failure, we error out.
+sub send_command($) {
+ print "Sending: $_[0]\n" if $debug;
+ my ($status, $text) = $client->send('', '', $_[0]);
+ print "Response: status $status, text $text\n" if $debug;
+ errorout "Premature end-of-file on IMAP connection to $host"
+ if $status eq 'EOF';
+ close_and_errorout "IMAP error for $mbox on $host: $text"
+ if $status ne 'OK';
+}
+
+# Callback subroutine to parse the QUOTA response.
+# The "-text" hash element contains the quota root name, and a list
+# of quota resource names, usages, and limits. Recognized names are
+# STORAGE (sum of message sizes, in kilobytes) and MESSAGE (number of
+# messages). See RFC 2087.
+sub quota_callback(@) {
+ my %cb = @_;
+ my ($root, $quotalist);
+ print "In QUOTA callback: text $cb{-text}\n" if $debug;
+ if (($root, $quotalist) = ($cb{-text} =~ /(\S*)\s+\((.*)\)/io)) {
+ my ($storage_used, $storage_max, $message_used, $message_max);
+ while ($quotalist) {
+ my ($resource, $used, $max);
+ ($resource, $used, $max, $quotalist) = split /\s/, $quotalist, 4;
+ last unless $max;
+ $resource = uc $resource;
+ if ($resource eq "STORAGE") {
+ $storage_used = $used;
+ $storage_max = $max;
+ }
+ elsif ($resource eq "MESSAGE") {
+ $message_used = $used;
+ $message_max = $max;
+ }
+ }
+ print_quota($root, $storage_used, $storage_max,
+ $message_used, $message_max)
+ if (defined $storage_max || defined $message_max);
+ }
+}
+
+# Callback subroutine to parse the QUOTAROOT response. The "-text"
+# hash element contains the mailbox name, and zero or more quota root
+# names. This is currently used for debugging only.
+sub quotaroot_callback(@) {
+ my %cb = @_;
+ print "In QUOTAROOT callback: text $cb{-text}\n" if $debug;
+}
+
+# Callback subroutine to parse the CAPABILITY response. The "-rock" hash
+# element is a reference to the string in which to store the space-separated
+# capability names.
+sub capability_callback(@) {
+ my %cb = @_;
+ print "In CAPABILITY callback: keyword $cb{-keyword}, text $cb{-text}\n"
+ if $debug;
+ ${$cb{-rock}} = $cb{-text};
+}
+
+# Close the connection to the IMAP server, and error out.
+sub close_and_errorout($) {
+ close_connection();
+ errorout $_[0];
+}
+
+# Logout from the IMAP server, and close the connection.
+sub close_connection() {
+ $client->send('', '', "LOGOUT");
+ # Set the client reference to undef, so that perl invokes the
+ # destructor, which closes the connection. Note that if we invoke
+ # the destructor explicitly here, then perl will still invoke it
+ # again when the program exits, thus touching memory which has
+ # already been freed.
+ $client = undef;
+}
+
+sub errorout($) {
+ print STDERR "mailquota: $_[0]\n";
+ exit 1;
+}
Copied: trunk/athena/bin/mitmailutils/bin/mailusage (from rev 25984, trunk/athena/bin/mitmailutils/mailusage.pl)
===================================================================
--- trunk/athena/bin/mitmailutils/bin/mailusage (rev 0)
+++ trunk/athena/bin/mitmailutils/bin/mailusage 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,205 @@
+#!/usr/bin/perl -w
+
+# $Id: mailusage.pl,v 1.4 2004-09-03 20:40:31 rbasch Exp $
+
+# Get the total size of, and number of messages in, mailboxes on an
+# IMAP server.
+
+use strict;
+use warnings FATAL => 'all';
+use Cyrus::IMAP;
+use Getopt::Std;
+
+sub usage(;$);
+sub get_usage($);
+sub send_command(@);
+sub list_callback(@);
+sub fetch_callback(@);
+sub number_callback(@);
+sub close_and_errorout($);
+sub close_connection();
+sub errorout($);
+
+sub usage(;$) {
+ print STDERR "mailusage: $_[0]\n" if $_[0];
+ print STDERR <<EOF;
+Usage: mailusage [<options>] [<user>]
+ Options:
+ -h <host> query <host> instead of default post office server
+ -m <mailbox> query for <mailbox> only (default is all)
+ -n suppress the header line
+ -r query recursively for all mailbox descendents
+ -s display only subscribed mailboxes
+ -d turn on debugging
+EOF
+ exit 1;
+}
+
+# Parse the command line arguments.
+my %opts;
+getopts('dh:m:nrs', \%opts) || usage;
+my $username = shift @ARGV || $ENV{'ATHENA_USER'} || $ENV{'USER'} || getlogin || (getpwuid($<))[0] ||
+ errorout "Cannot determine user name";
+
+usage "Too many arguments" if @ARGV > 0;
+my $debug = $opts{'d'};
+my $host = $opts{'h'} || (gethostbyname("$username.mail.mit.edu"))[0];
+errorout "Cannot find Post Office server for $username" unless $host;
+errorout "Exchange accounts are not supported yet. Try http://owa.mit.edu/." if $host =~ /EXCHANGE/;
+my $mbox = $opts{'m'} || '*';
+my $noheader = $opts{'n'};
+my $recurse = $opts{'r'};
+my $list_cmd = ($opts{'s'} ? 'LSUB' : 'LIST');
+
+# Connect to the IMAP server, and authenticate.
+my $client = Cyrus::IMAP->new($host) ||
+ errorout "Cannot connect to IMAP server on $host";
+unless ($client->authenticate(-authz => $username, -maxssf => 0)) {
+ close_connection();
+ errorout "Cannot authenticate to $host";
+}
+
+# Get all mailboxes of interest. %mailboxes is a hash whose keys are
+# the mailbox names; the values are hashes with "attributes" and
+# "delimiter" keys.
+my %mailboxes = ();
+$client->addcallback({-trigger => $list_cmd,
+ -callback => \&list_callback,
+ -rock => \%mailboxes});
+
+# First list the given mailbox.
+send_command("$list_cmd %s %s", '', $mbox);
+
+# If recursing, also list all descendents of the mailbox, unless the
+# given name contains a trailing wildcard.
+send_command("$list_cmd %s %s%s*", '', $mbox, $mailboxes{$mbox}{delimiter})
+ if ($recurse && $mailboxes{$mbox} && $mailboxes{$mbox}{delimiter} &&
+ $mbox !~ m/\*$/o);
+
+if (%mailboxes) {
+ # We now have all of the mailboxes of interest. Get and display
+ # the total size and number of messages for each one.
+ foreach my $name (sort keys %mailboxes) {
+ # Skip any mailbox that cannot be selected.
+ next if $mailboxes{$name}{attributes} =~ m/\\Noselect\b/;
+ my ($size, $nmsgs) = get_usage($name);
+ unless ($noheader) {
+ print "Size in KB #Messages Mailbox\n";
+ $noheader = 1;
+ }
+ printf("%10d %10d %s\n", int(($size + 1023) / 1024), $nmsgs, $name);
+ }
+} else {
+ close_and_errorout "No such mailbox \"$mbox\"";
+}
+
+# We are done talking to the IMAP server; close down the connection.
+close_connection();
+
+# Subroutine to obtain the usage for a given mailbox name. It returns
+# the total size, i.e. a sum of sizes of all messages in the mailbox,
+# and the number of messages.
+sub get_usage($) {
+ my $mbox = $_[0];
+ my %usage = (totalsize => 0, msgcount => 0);
+ my $exists = 0;
+ my $cb_numbered = Cyrus::IMAP::CALLBACK_NUMBERED;
+ $client->addcallback({-trigger => 'EXISTS', -flags => $cb_numbered,
+ -callback => \&number_callback,
+ -rock => \$exists});
+ # Select the mailbox for read-only operations.
+ send_command("EXAMINE %s", $mbox);
+ # If this mailbox has messages, fetch their size.
+ if ($exists) {
+ # The fetch callback will update the values for totalsize and
+ # msgcount in the %usage hash.
+ $client->addcallback({-trigger => 'FETCH', -flags => $cb_numbered,
+ -callback => \&fetch_callback,
+ -rock => \%usage});
+ send_command("FETCH 1:* RFC822.SIZE");
+ }
+ return ($usage{totalsize}, $usage{msgcount});
+}
+
+# Subroutine to send a command to the IMAP server, and wait for the
+# response; any defined callbacks for the response are invoked.
+# If the server response indicates failure, we error out.
+sub send_command(@) {
+ my ($fmt, @args) = @_;
+ printf("Sending: $fmt\n", @args) if $debug;
+ my ($status, $text) = $client->send('', '', $fmt, @args);
+ print "Response: status $status, text $text\n" if $debug;
+ errorout "Premature end-of-file on IMAP connection to $host"
+ if $status eq 'EOF';
+ close_and_errorout "IMAP error from $host: $text"
+ if $status ne 'OK';
+}
+
+# Callback to parse a LIST (or LSUB) response for a mailbox name
+# and its attributes and delimiter.
+#
+# The response contains three elements, of the form:
+#
+# (<attribute> ...) <delimiter> "<name>"
+#
+# For example:
+#
+# (\HasChildren) "." "INBOX"
+#
+# The delimiter is either a quoted single character, e.g. ".",
+# or NIL.
+#
+# The "-rock" hash element is a reference to a hash to which we add a
+# key for the mailbox name, with its value being a hash with "attributes"
+# and "delimiter" keys. For a NIL delimiter, the returned value is undef,
+# indicating a flat name.
+sub list_callback(@) {
+ my %cb = @_;
+ print "In LIST callback: text $cb{-text}\n" if $debug;
+ return unless $cb{-text} =~ m/^\(([^\)]*)\)\s+(?:"(.)"|NIL)\s+"(.+)"/o;
+ ${$cb{-rock}}{$3} = {attributes => $1, delimiter => $2};
+}
+
+# Callback to parse the response from a "FETCH ... RFC822.SIZE"
+# command for one message. The "-rock" element is a reference to a
+# hash containing totalsize and msgcount keys, whose values will be
+# updated accordingly.
+sub fetch_callback(@) {
+ my %cb = @_;
+ print "In FETCH callback: text $cb{-text}\n" if $debug;
+ if ($cb{-text} =~ /RFC822.SIZE\s+(\d+)/io) {
+ ${$cb{-rock}}{totalsize} += $1;
+ ${$cb{-rock}}{msgcount}++;
+ }
+}
+
+# Callback to parse a numeric value. The "-rock" element is a
+# reference to the scalar in which to store the number.
+sub number_callback(@) {
+ my %cb = @_;
+ print "In number callback: keyword $cb{-keyword}, number $cb{-msgno}\n"
+ if $debug;
+ ${$cb{-rock}} = $cb{-msgno};
+}
+
+# Close the connection to the IMAP server, and error out.
+sub close_and_errorout($) {
+ close_connection();
+ errorout $_[0];
+}
+
+# Logout from the IMAP server, and close the connection.
+sub close_connection() {
+ $client->send('', '', "LOGOUT");
+ # Set the client reference to undef, so that perl invokes the
+ # destructor, which closes the connection. Note that if we invoke
+ # the destructor explicitly here, then perl will still invoke it
+ # again when the program exits, thus touching memory which has
+ # already been freed.
+ $client = undef;
+}
+
+sub errorout($) {
+ print STDERR "mailusage: $_[0]\n";
+ exit 1;
+}
Copied: trunk/athena/bin/mitmailutils/bin/mitmailappend (from rev 25984, trunk/athena/bin/mitmailutils/mitmailappend.pl)
===================================================================
--- trunk/athena/bin/mitmailutils/bin/mitmailappend (rev 0)
+++ trunk/athena/bin/mitmailutils/bin/mitmailappend 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,144 @@
+#!/usr/bin/perl -w
+
+# $Id: mitmailappend.pl,v 1.1 2004-09-03 20:44:43 rbasch Exp $
+
+# Append a message to an IMAP folder.
+
+use strict;
+use warnings FATAL => 'all';
+use Cyrus::IMAP;
+use Getopt::Long;
+
+sub usage(;$);
+sub read_file($);
+sub send_command(@);
+sub close_and_errorout($);
+sub close_connection();
+sub errorout($);
+
+my $prog = $0;
+
+sub usage(;$) {
+ print STDERR "$prog: $_[0]\n" if ($_[0] && $_[0] ne "help");
+ print STDERR <<EOF;
+Usage: $prog [<options>]
+ Options:
+ --debug turn on debugging
+ --file=<path> read message from <path> instead of standard input
+ --help print this usage information
+ --host=<name> query host <name> instead of default POBOX server
+ --mailbox=<name> access mailbox <name> instead of INBOX
+ --no-create do not create the target mailbox automatically
+EOF
+ exit 1;
+}
+
+# Parse the command line arguments.
+use vars qw($opt_debug $opt_file $opt_host $opt_mailbox $opt_no_create);
+
+GetOptions("debug",
+ "file=s",
+ "help" => \&usage,
+ "host=s",
+ "mailbox=s",
+ "no-create") || usage;
+
+usage unless @ARGV == 0;
+
+$opt_mailbox = "INBOX" unless $opt_mailbox;
+
+# By default we read the message from standard input.
+$opt_file = "-" unless $opt_file;
+
+my $username = $ENV{'ATHENA_USER'} || $ENV{'USER'} || getlogin || (getpwuid($<))[0] ||
+ errorout "Cannot determine user name";
+
+unless ($opt_host) {
+ $opt_host = (gethostbyname("$username.mail.mit.edu"))[0];
+ errorout "Cannot find Post Office server for $username" unless $opt_host;
+}
+errorout "Exchange accounts are not supported yet. Try http://owa.mit.edu/." if $opt_host =~ /EXCHANGE/;
+
+# Read the entire message file into a string.
+my $msg = read_file($opt_file);
+
+# Convert LF -> CRLF if necessary.
+unless ($msg =~ m/\r\n/os) {
+ print "Converting LF to CRLF...\n" if $opt_debug;
+ $msg =~ s/\n/\r\n/gos;
+}
+
+# Connect to the IMAP server, and authenticate.
+my $client = Cyrus::IMAP->new($opt_host) ||
+ errorout "Cannot connect to IMAP server on $opt_host";
+$client->authenticate(-authz => $username, -maxssf => 0) ||
+ close_and_errorout "Cannot authenticate to $opt_host";
+
+# Try the APPEND command. If the server returns an error,
+# check for "TRYCREATE" in the response text; this is a hint that
+# the target mailbox does not exist, but that it can be created.
+my ($status, $text) = send_command("APPEND %s %s", $opt_mailbox, $msg);
+if ($status ne 'OK') {
+ if ($text =~ m/\bTRYCREATE\b/io) {
+ close_and_errorout "Mailbox $opt_mailbox does not exist"
+ if $opt_no_create;
+ print "Creating $opt_mailbox\n" if $opt_debug;
+ # send_command will error out if the CREATE fails.
+ send_command("CREATE %s", $opt_mailbox);
+ ($status, $text) = send_command("APPEND %s %s", $opt_mailbox, $msg);
+ }
+ close_and_errorout "IMAP error from $opt_host: $text"
+ if ($status ne 'OK');
+}
+
+# We are done talking to the IMAP server, close down the connection.
+close_connection();
+
+exit 0;
+
+# Read the given file's entire contents, returning it as a scalar.
+sub read_file($) {
+ my $file = $_[0];
+ local $/ = undef;
+ open(FILE, $file) || errorout "Cannot open $file: $!";
+ my $contents = <FILE>;
+ close(FILE);
+ return $contents;
+}
+
+# Subroutine to send a command to the IMAP server, and wait for the
+# response. If the response status indicates failure (i.e. is not
+# "OK"), we error out.
+sub send_command(@) {
+ my ($fmt, @args) = @_;
+ printf("Sending: $fmt\n", @args) if $opt_debug;
+ my ($status, $text) = $client->send('', '', $fmt, @args);
+ errorout "Premature end-of-file on IMAP connection to $opt_host"
+ if $status eq 'EOF';
+ print "Response: status $status, text $text\n" if $opt_debug;
+ return ($status, $text) if wantarray;
+ close_and_errorout "IMAP error from $opt_host: $text"
+ if $status ne 'OK';
+}
+
+# Close the connection to the IMAP server, and error out.
+sub close_and_errorout($) {
+ close_connection();
+ errorout $_[0];
+}
+
+# Logout from the IMAP server, and close the connection.
+sub close_connection() {
+ $client->send('', '', "LOGOUT");
+ # Set the client reference to undef, so that perl invokes the
+ # destructor, which closes the connection. Note that if we invoke
+ # the destructor explicitly here, then perl will still invoke it
+ # again when the program exits, thus touching memory which has
+ # already been freed.
+ $client = undef;
+}
+
+sub errorout($) {
+ print STDERR "$prog: $_[0]\n";
+ exit 1;
+}
Copied: trunk/athena/bin/mitmailutils/bin/mitmailcreate (from rev 25984, trunk/athena/bin/mitmailutils/mitmailcreate.pl)
===================================================================
--- trunk/athena/bin/mitmailutils/bin/mitmailcreate (rev 0)
+++ trunk/athena/bin/mitmailutils/bin/mitmailcreate 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,130 @@
+#!/usr/bin/perl -w
+
+# $Id: mitmailcreate.pl,v 1.2 2004-07-29 19:11:52 rbasch Exp $
+
+# Create, remove, subscribe to or unsubscribe to IMAP mailboxes.
+
+use strict;
+use warnings FATAL => 'all';
+use Cyrus::IMAP;
+use Getopt::Long;
+
+sub usage(;$);
+sub send_command($);
+sub close_connection();
+sub errorout($);
+
+my $prog = $0;
+
+my $imap_cmd;
+my $create = 0;
+my $create_subscribe_cmd;
+
+if ($prog =~ m/create/o) {
+ $create = 1;
+ $imap_cmd = 'CREATE';
+ # If the --no-subscribe option is given, we will unsubscribe the
+ # mailbox explicitly, as a formerly existing mailbox of the same
+ # name may still be in the subscription list.
+ $create_subscribe_cmd = 'SUBSCRIBE';
+} elsif ($prog =~ m/remove/o) {
+ $imap_cmd = 'DELETE';
+} elsif ($prog =~ m/unsubscribe/o) {
+ $imap_cmd = 'UNSUBSCRIBE';
+} elsif ($prog =~ m/subscribe/o) {
+ $imap_cmd = 'SUBSCRIBE';
+}
+
+sub usage(;$) {
+ print STDERR "$prog: $_[0]\n" if ($_[0] && $_[0] ne "help");
+ print STDERR <<EOF;
+Usage: $prog [<options>]
+ Options:
+ --debug turn on debugging
+ --help print this usage information
+ --host=<name> query host <name> instead of default POBOX server
+EOF
+ if ($create) {
+ print STDERR <<EOF;
+ --no-subscribe do not add to list of subscribed mailboxes
+EOF
+ }
+ exit 1;
+}
+
+# Parse the command line arguments.
+use vars qw($opt_debug $opt_host $opt_no_subscribe);
+
+GetOptions("debug",
+ "help" => \&usage,
+ "host=s",
+ "no-subscribe" => sub {
+ unless ($create) {
+ usage "Unknown option: no-subscribe";
+ }
+ $opt_no_subscribe = 1;
+ $create_subscribe_cmd = 'UNSUBSCRIBE';
+ }
+ ) || usage;
+
+usage "Please specify a mailbox name" if @ARGV == 0;
+
+my $username = $ENV{'ATHENA_USER'} || $ENV{'USER'} || getlogin || (getpwuid($<))[0] ||
+ errorout "Cannot determine user name";
+
+unless ($opt_host) {
+ $opt_host = (gethostbyname("$username.mail.mit.edu"))[0];
+ errorout "Cannot find Post Office server for $username" unless $opt_host;
+}
+errorout "Exchange accounts are not supported yet. Try http://owa.mit.edu/." if $opt_host =~ /EXCHANGE/;
+
+# Connect to the IMAP server, and authenticate.
+my $client = Cyrus::IMAP->new($opt_host) ||
+ errorout "Cannot connect to IMAP server on $opt_host";
+unless ($client->authenticate(-authz => $username, -maxssf => 0)) {
+ close_connection();
+ errorout "Cannot authenticate to $opt_host";
+}
+
+# Loop to act upon mailboxes given on the command line.
+foreach (@ARGV) {
+ send_command "$imap_cmd \"$_\"";
+ # If creating the mailbox, subscribe or unsubscribe to it.
+ if ($create) {
+ send_command "$create_subscribe_cmd \"$_\"";
+ }
+}
+
+# We are done talking to the IMAP server, close down the connection.
+close_connection();
+
+# Subroutine to send a command to the IMAP server, and wait for the
+# response; any defined callbacks for the response are invoked.
+# If the server response indicates failure, we error out.
+sub send_command($) {
+ print "Sending: $_[0]\n" if $opt_debug;
+ my ($status, $text) = $client->send('', '', $_[0]);
+ print "Response: status $status, text $text\n" if $opt_debug;
+ errorout "Premature end-of-file on IMAP connection to $opt_host"
+ if $status eq 'EOF';
+ if ($status ne 'OK') {
+ close_connection();
+ errorout "IMAP error on $opt_host: $text"
+ }
+}
+
+# Logout from the IMAP server, and close the connection.
+sub close_connection() {
+ $client->send('', '', "LOGOUT");
+ # Set the client reference to undef, so that perl invokes the
+ # destructor, which closes the connection. Note that if we invoke
+ # the destructor explicitly here, then perl will still invoke it
+ # again when the program exits, thus touching memory which has
+ # already been freed.
+ $client = undef;
+}
+
+sub errorout($) {
+ print STDERR "$prog: $_[0]\n";
+ exit 1;
+}
Copied: trunk/athena/bin/mitmailutils/bin/mitmaildel (from rev 25984, trunk/athena/bin/mitmailutils/mitmaildel.pl)
===================================================================
--- trunk/athena/bin/mitmailutils/bin/mitmaildel (rev 0)
+++ trunk/athena/bin/mitmailutils/bin/mitmaildel 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,235 @@
+#!/usr/bin/perl -w
+
+# $Id: mitmaildel.pl,v 1.3 2004-07-29 19:11:52 rbasch Exp $
+
+# Delete (or undelete) messages in an IMAP folder.
+
+use strict;
+use warnings FATAL => 'all';
+use Cyrus::IMAP;
+use Getopt::Long;
+
+sub usage(;$);
+sub send_command($);
+sub fetch_callback(@);
+sub number_callback(@);
+sub close_and_errorout($);
+sub close_connection();
+sub errorout($);
+
+my $prog = $0;
+my $undelete = ($prog =~ m/undel$/o);
+
+sub usage(;$) {
+ print STDERR "$prog: $_[0]\n" if ($_[0] && $_[0] ne "help");
+ print STDERR <<EOF;
+Usage: $prog [<options>] <message-id> ...
+ Options:
+ --by-uid specify message UIDs instead of sequence numbers
+ --debug turn on debugging
+ --expunge expunge all deleted messages from mailbox
+ --help print this usage information
+ --host=<name> query host <name> instead of default POBOX server
+ --mailbox=<name> examine mailbox <name> instead of INBOX
+ --silent suppress acknowledgement output
+EOF
+ exit 1;
+}
+
+# Parse the command line arguments.
+use vars qw($opt_by_uid $opt_debug $opt_expunge $opt_host
+ $opt_mailbox $opt_silent);
+
+GetOptions("by-uid",
+ "debug",
+ "expunge",
+ "help" => \&usage,
+ "host=s",
+ "mailbox=s",
+ "silent") || usage;
+
+usage "Please specify a message number" if @ARGV == 0;
+
+# Check the validity of message ID arguments.
+# The ID can be a number or '*', and we accept a range specification,
+# of the form 'n:m'.
+foreach (@ARGV) {
+ errorout "Invalid message specification $_"
+ unless (m/^(?:\d+|\*)(?::(?:\d+|\*))?$/o);
+}
+
+$opt_mailbox = 'INBOX' unless $opt_mailbox;
+
+my $username = $ENV{'ATHENA_USER'} || $ENV{'USER'} || getlogin || (getpwuid($<))[0] ||
+ errorout "Cannot determine user name";
+
+unless ($opt_host) {
+ $opt_host = (gethostbyname("$username.mail.mit.edu"))[0];
+ errorout "Cannot find Post Office server for $username" unless $opt_host;
+}
+errorout "Exchange accounts are not supported yet. Try http://owa.mit.edu/." if $opt_host =~ /EXCHANGE/;
+
+# Connect to the IMAP server, and authenticate.
+my $client = Cyrus::IMAP->new($opt_host) ||
+ errorout "Cannot connect to IMAP server on $opt_host";
+$client->authenticate(-authz => $username, -maxssf => 0) ||
+ close_and_errorout "Cannot authenticate to $opt_host";
+
+# Select the mailbox (for read-write access). Store the value of the
+# EXISTS (i.e. highest existing message sequence number) data item,
+# and, if returned, the UIDNEXT (next UID to be assigned) value.
+my $cb_numbered = Cyrus::IMAP::CALLBACK_NUMBERED;
+my $maxseq = 0;
+my $uidnext = 0;
+$client->addcallback({-trigger => 'EXISTS', -flags => $cb_numbered,
+ -callback => \&number_callback,
+ -rock => \$maxseq});
+$client->addcallback({-trigger => 'OK',
+ -callback => sub {
+ my %cb = @_;
+ print "In OK callback: text $cb{-text}\n"
+ if $opt_debug;
+ return unless ($cb{-text} =~ m/UIDNEXT\s+(\d+)/io);
+ $uidnext = $1;
+ }});
+send_command "SELECT \"$opt_mailbox\"";
+
+# If we're operating on UIDs, and did not get the UIDNEXT value above,
+# use the STATUS command to get it explicitly.
+if ($opt_by_uid && !$uidnext) {
+ $client->addcallback({-trigger => 'STATUS',
+ -callback => sub {
+ my %cb = @_;
+ print "In STATUS callback: text $cb{-text}\n"
+ if $opt_debug;
+ return
+ unless ($cb{-text} =~ m/UIDNEXT\s+(\d+)/io);
+ $uidnext = $1;
+ }});
+ send_command "STATUS \"$opt_mailbox\" (UIDNEXT)";
+}
+
+# Note that the STORE command returns success even when the given
+# message ID does not exist. So the most feasible way to determine
+# whether the (un)delete was successful for a message is to see if the
+# FETCH callback (invoked during the server response to the STORE
+# command) was invoked for the message, and whether the \Deleted flag
+# was returned. We thus initialize a hash whose keys are the
+# individual message IDs given; the FETCH callback will remove the key
+# from the hash when it detects that the message flags have been set
+# as desired. Any keys remaining in the hash upon completion will
+# indicate IDs whose flags could not be modified (presumably because
+# the message does not exist).
+my %unchanged = ();
+my $expect = ($undelete ? "undeleted" : "deleted");
+my $exitcode = 0;
+my $store_cmd = ($opt_by_uid ? 'UID STORE' : 'STORE');
+my $store_item = ($undelete ? '-FLAGS' : '+FLAGS');
+$client->addcallback({-trigger => 'FETCH', -flags => $cb_numbered,
+ -callback => \&fetch_callback,
+ -rock => \%unchanged});
+foreach (@ARGV) {
+ if ($opt_by_uid) {
+ # When operating on UIDs, the message numbers in a range are
+ # not necessarily sequential, so we don't detect unchanged
+ # messages in the range. We can handle '*', though, as that
+ # is simply one less than the next UID to be assigned.
+ $_ = ($uidnext - 1) if ($_ eq '*' && $uidnext);
+ %unchanged = ($_ => 1) if (/^\d+$/);
+ } else {
+ s/\*/$maxseq/o;
+ m/^(\d+)(?::(\d+))?$/o;
+ if ($2) {
+ %unchanged = map { $_ => 1 } ($1 < $2 ? $1 .. $2 : $2 .. $1);
+ } else {
+ %unchanged = ($1 => 1);
+ }
+ }
+ send_command "$store_cmd $_ $store_item (\\Deleted)";
+ foreach my $msg (sort { $a <=> $b } keys %unchanged) {
+ print STDERR "$prog: Could not " .
+ ($undelete ? "un" : "") . "delete $msg\n";
+ $exitcode = 1;
+ }
+}
+
+# Expunge the mailbox if so desired, unless there was an error marking
+# any message.
+send_command "CLOSE" if ($opt_expunge && ($exitcode == 0));
+
+# We are done talking to the IMAP server, close down the connection.
+close_connection();
+
+exit $exitcode;
+
+# Subroutine to send a command to the IMAP server, and wait for the
+# response; any defined callbacks for the response are invoked.
+# If the server response indicates failure, we error out.
+sub send_command($) {
+ print "Sending: $_[0]\n" if $opt_debug;
+ my ($status, $text) = $client->send('', '', $_[0]);
+ print "Response: status $status, text $text\n" if $opt_debug;
+ errorout "Premature end-of-file on IMAP connection to $opt_host"
+ if $status eq 'EOF';
+ close_and_errorout "IMAP error from $opt_host: $text"
+ if $status ne 'OK';
+}
+
+# Callback subroutine to parse the FETCH response from a STORE command.
+# This callback will be invoked for each message. The "-text" hash
+# element contains the text returned by the server. The "-rock"
+# element is a reference to the hash containing the message IDs of
+# interest; we delete the appropriate key (sequence number or UID)
+# from this hash.
+sub fetch_callback(@) {
+ my %cb = @_;
+ my ($number, $flags);
+ print "In FETCH callback: msgno $cb{-msgno} text $cb{-text}\n"
+ if $opt_debug;
+ $number = $cb{-msgno};
+ foreach (split /\r\n/, $cb{-text}) {
+ $number = $1 if /UID\s+(\d+)/io;
+ $flags = $1 if /FLAGS\s+\(([^\)]*)\)/io;
+ }
+ delete ${$cb{-rock}}{$number};
+ my $state = ($flags =~ /\\Deleted\b/io ? "deleted" : "undeleted");
+ # Warn if the returned state is not what was expected.
+ if ($state ne $expect) {
+ print STDERR "$prog: Warning: Message $number $state\n";
+ } else {
+ # Display an acknowledgement of success if so desired.
+ print(($opt_by_uid ? "UID" : "Message") . " $number $state\n")
+ unless $opt_silent;
+ }
+}
+
+# Callback subroutine to parse a numeric value. The "-rock" hash
+# element is a reference to the scalar in which to store the number.
+sub number_callback(@) {
+ my %cb = @_;
+ print "In number callback: keyword $cb{-keyword}, number $cb{-msgno}\n"
+ if $opt_debug;
+ ${$cb{-rock}} = $cb{-msgno};
+}
+
+# Close the connection to the IMAP server, and error out.
+sub close_and_errorout($) {
+ close_connection();
+ errorout $_[0];
+}
+
+# Logout from the IMAP server, and close the connection.
+sub close_connection() {
+ $client->send('', '', "LOGOUT");
+ # Set the client reference to undef, so that perl invokes the
+ # destructor, which closes the connection. Note that if we invoke
+ # the destructor explicitly here, then perl will still invoke it
+ # again when the program exits, thus touching memory which has
+ # already been freed.
+ $client = undef;
+}
+
+sub errorout($) {
+ print STDERR "$prog: $_[0]\n";
+ exit 1;
+}
Copied: trunk/athena/bin/mitmailutils/bin/mitmailexp (from rev 25984, trunk/athena/bin/mitmailutils/mitmailexp.pl)
===================================================================
--- trunk/athena/bin/mitmailutils/bin/mitmailexp (rev 0)
+++ trunk/athena/bin/mitmailutils/bin/mitmailexp 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,102 @@
+#!/usr/bin/perl -w
+
+# $Id: mitmailexp.pl,v 1.3 2004-07-29 19:11:53 rbasch Exp $
+
+# Expunge an IMAP folder.
+
+use strict;
+use warnings FATAL => 'all';
+use Cyrus::IMAP;
+use Getopt::Long;
+
+sub usage(;$);
+sub send_command($);
+sub fetch_callback(@);
+sub number_callback(@);
+sub make_msgspecs(@);
+sub close_connection();
+sub errorout($);
+
+my $prog = $0;
+
+sub usage(;$) {
+ print STDERR "$prog: $_[0]\n" if ($_[0] && $_[0] ne "help");
+ print STDERR <<EOF;
+Usage: $prog [<options>]
+ Options:
+ --debug turn on debugging
+ --help print this usage information
+ --host=<name> query host <name> instead of default POBOX server
+ --mailbox=<name> examine mailbox <name> instead of INBOX
+EOF
+ exit 1;
+}
+
+# Parse the command line arguments.
+use vars qw($opt_debug $opt_host $opt_mailbox);
+
+GetOptions("debug",
+ "help" => \&usage,
+ "host=s",
+ "mailbox=s") || usage;
+
+usage "Too many arguments" if @ARGV > 0;
+
+$opt_mailbox = 'INBOX' unless $opt_mailbox;
+
+my $username = $ENV{'ATHENA_USER'} || $ENV{'USER'} || getlogin || (getpwuid($<))[0] ||
+ errorout "Cannot determine user name";
+
+unless ($opt_host) {
+ $opt_host = (gethostbyname("$username.mail.mit.edu"))[0];
+ errorout "Cannot find Post Office server for $username" unless $opt_host;
+}
+errorout "Exchange accounts are not supported yet. Try http://owa.mit.edu/." if $opt_host =~ /EXCHANGE/;
+
+# Connect to the IMAP server, and authenticate.
+my $client = Cyrus::IMAP->new($opt_host) ||
+ errorout "Cannot connect to IMAP server on $opt_host";
+unless ($client->authenticate(-authz => $username, -maxssf => 0)) {
+ close_connection();
+ errorout "Cannot authenticate to $opt_host";
+}
+
+# Access the mailbox. Make sure we have read-write access.
+send_command "SELECT \"$opt_mailbox\"";
+
+# Close the mailbox, thereby expunging deleted messages.
+send_command "CLOSE";
+
+# We are done talking to the IMAP server, close down the connection.
+close_connection();
+
+# Subroutine to send a command to the IMAP server, and wait for the
+# response; any defined callbacks for the response are invoked.
+# If the server response indicates failure, we error out.
+sub send_command($) {
+ print "Sending: $_[0]\n" if $opt_debug;
+ my ($status, $text) = $client->send('', '', $_[0]);
+ print "Response: status $status, text $text\n" if $opt_debug;
+ errorout "Premature end-of-file on IMAP connection to $opt_host"
+ if $status eq 'EOF';
+ if ($status ne 'OK') {
+ close_connection();
+ errorout "IMAP error for $opt_mailbox on $opt_host: $text"
+ }
+}
+
+# Logout from the IMAP server, and close the connection.
+sub close_connection() {
+ $client->send('', '', "LOGOUT");
+ # Set the client reference to undef, so that perl invokes the
+ # destructor, which closes the connection. Note that if we invoke
+ # the destructor explicitly here, then perl will still invoke it
+ # again when the program exits, thus touching memory which has
+ # already been freed.
+ $client = undef;
+}
+
+sub errorout($) {
+ print STDERR "$prog: $_[0]\n";
+ exit 1;
+}
Copied: trunk/athena/bin/mitmailutils/bin/mitmailmove (from rev 25984, trunk/athena/bin/mitmailutils/mitmailmove.pl)
===================================================================
--- trunk/athena/bin/mitmailutils/bin/mitmailmove (rev 0)
+++ trunk/athena/bin/mitmailutils/bin/mitmailmove 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,185 @@
+#!/usr/bin/perl -w
+
+# $Id: mitmailmove.pl,v 1.3 2004-08-31 16:00:16 rbasch Exp $
+
+# Move or copy messages between IMAP folders.
+
+use strict;
+use warnings FATAL => 'all';
+use Cyrus::IMAP;
+use Getopt::Long;
+
+sub usage(;$);
+sub send_command($);
+sub fetch_callback(@);
+sub close_and_errorout($);
+sub close_connection();
+sub errorout($);
+
+my $prog = $0;
+my $copy = ($prog =~ m/copy$/o);
+
+sub usage(;$) {
+ print STDERR "$prog: $_[0]\n" if ($_[0] && $_[0] ne "help");
+ print STDERR <<EOF;
+Usage: $prog [<options>] <message-id> [...] <target-mailbox>
+ Options:
+ --by-uid specify message UIDs instead of sequence numbers
+ --debug turn on debugging
+ --help print this usage information
+ --host=<name> query host <name> instead of default POBOX server
+ --mailbox=<name> examine mailbox <name> instead of INBOX
+ --no-create do not create the target mailbox automatically
+EOF
+ exit 1;
+}
+
+# Parse the command line arguments.
+use vars qw($opt_by_uid $opt_debug $opt_host $opt_mailbox $opt_no_create);
+
+GetOptions("by-uid",
+ "debug",
+ "help" => \&usage,
+ "host=s",
+ "mailbox=s",
+ "no-create") || usage;
+
+usage "Please specify a message number and target mailbox" if @ARGV < 2;
+my $target = pop @ARGV;
+
+# Check the validity of message ID arguments.
+# The ID can be a number or '*', and we accept a range specification,
+# of the form 'n:m'.
+foreach (@ARGV) {
+ errorout "Invalid message specification $_"
+ unless (m/^(?:\d+|\*)(?::(?:\d+|\*))?$/o);
+}
+
+$opt_mailbox = 'INBOX' unless $opt_mailbox;
+
+my $username = $ENV{'ATHENA_USER'} || $ENV{'USER'} || getlogin || (getpwuid($<))[0] ||
+ errorout "Cannot determine user name";
+
+unless ($opt_host) {
+ $opt_host = (gethostbyname("$username.mail.mit.edu"))[0];
+ errorout "Cannot find Post Office server for $username" unless $opt_host;
+}
+errorout "Exchange accounts are not supported yet. Try http://owa.mit.edu/." if $opt_host =~ /EXCHANGE/;
+
+# Connect to the IMAP server, and authenticate.
+my $client = Cyrus::IMAP->new($opt_host) ||
+ errorout "Cannot connect to IMAP server on $opt_host";
+$client->authenticate(-authz => $username, -maxssf => 0) ||
+ close_and_errorout "Cannot authenticate to $opt_host";
+
+# Select (or examine, if copying only) the mailbox.
+my $select_cmd = ($copy ? 'EXAMINE' : 'SELECT');
+send_command "$select_cmd \"$opt_mailbox\"";
+
+# Use the correct forms of the COPY and STORE commands, depending on
+# whether we are operating on UIDs, or sequence numbers.
+my $store_cmd;
+my $copy_cmd;
+if ($opt_by_uid) {
+ $copy_cmd = 'UID COPY';
+ $store_cmd = 'UID STORE';
+} else {
+ $copy_cmd = 'COPY';
+ $store_cmd = 'STORE';
+}
+
+# If we are doing a "move" operation, we will execute a STORE command
+# following the copy to set the message's Deleted flag. Add a callback
+# for the FETCH response generated by the STORE.
+my $cb_numbered = Cyrus::IMAP::CALLBACK_NUMBERED;
+unless ($copy) {
+ $client->addcallback({-trigger => 'FETCH', -flags => $cb_numbered,
+ -callback => \&fetch_callback});
+}
+
+# Copy each given message ID to the target mailbox, and, if doing a
+# "move", mark the source message(s) for deletion.
+my $exitcode = 0;
+foreach (@ARGV) {
+ my ($status, $text) = send_command "$copy_cmd $_ \"$target\"";
+ if ($status ne 'OK') {
+ if ($text =~ m/\bTRYCREATE\b/io) {
+ close_and_errorout "Mailbox $target does not exist"
+ if $opt_no_create;
+ print "Creating $target\n" if $opt_debug;
+ # send_command will error out if either the CREATE fails.
+ send_command "CREATE \"$target\"";
+ ($status, $text) = send_command "$copy_cmd $_ \"$target\"";
+ }
+ if ($status ne 'OK') {
+ print STDERR "IMAP error copying $_ to $target: $text\n";
+ $exitcode = 2;
+ next;
+ }
+ }
+ send_command "$store_cmd $_ +FLAGS (\\Deleted)" unless $copy;
+}
+
+# We are done talking to the IMAP server, close down the connection.
+close_connection();
+
+exit $exitcode;
+
+# Subroutine to send a command to the IMAP server, and wait for the
+# response; any defined callbacks for the response are invoked.
+# If called in list context, we return the server's response, as
+# status and text values. Otherwise, if the response indicates
+# failure, we error out.
+sub send_command($) {
+ print "Sending: $_[0]\n" if $opt_debug;
+ my ($status, $text) = $client->send('', '', $_[0]);
+ print "Response: status $status, text $text\n" if $opt_debug;
+ errorout "Premature end-of-file on IMAP connection to $opt_host"
+ if $status eq 'EOF';
+ return ($status, $text) if wantarray;
+ close_and_errorout "IMAP error from $opt_host: $text"
+ if $status ne 'OK';
+}
+
+# Callback subroutine to parse the FETCH response from a STORE command.
+# This callback will be invoked for each message. The "-text" hash
+# element contains the text returned by the server.
+sub fetch_callback(@) {
+ my %cb = @_;
+ my ($number, $flags);
+ print "In FETCH callback: msgno $cb{-msgno} text $cb{-text}\n"
+ if $opt_debug;
+ $number = $cb{-msgno};
+ foreach (split /\r\n/, $cb{-text}) {
+ $number = $1 if /UID\s+(\d+)/io;
+ $flags = $1 if /FLAGS\s+\(([^\)]*)\)/io;
+ }
+ # Warn if the message's state does not include the Deleted flag
+ # (should never happen).
+ if ($flags !~ m/\\Deleted\b/io) {
+ print STDERR "$prog: Warning: Message $number not deleted";
+ print STDERR " from $opt_mailbox\n";
+ }
+}
+
+# Close the connection to the IMAP server, and error out.
+sub close_and_errorout($) {
+ close_connection();
+ errorout $_[0];
+}
+
+# Logout from the IMAP server, and close the connection.
+sub close_connection() {
+ $client->send('', '', "LOGOUT");
+ # Set the client reference to undef, so that perl invokes the
+ # destructor, which closes the connection. Note that if we invoke
+ # the destructor explicitly here, then perl will still invoke it
+ # again when the program exits, thus touching memory which has
+ # already been freed.
+ $client = undef;
+}
+
+sub errorout($) {
+ print STDERR "$prog: $_[0]\n";
+ exit 1;
+}
Copied: trunk/athena/bin/mitmailutils/bin/mitmailrename (from rev 25984, trunk/athena/bin/mitmailutils/mitmailrename.pl)
===================================================================
--- trunk/athena/bin/mitmailutils/bin/mitmailrename (rev 0)
+++ trunk/athena/bin/mitmailutils/bin/mitmailrename 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,90 @@
+#!/usr/bin/perl -w
+
+# $Id: mitmailrename.pl,v 1.2 2004-07-29 19:11:53 rbasch Exp $
+
+# Rename an IMAP folder.
+
+use strict;
+use warnings FATAL => 'all';
+use Cyrus::IMAP;
+use Getopt::Long;
+
+sub usage(;$);
+sub send_command($);
+sub close_connection();
+sub errorout($);
+
+my $prog = $0;
+
+sub usage(;$) {
+ print STDERR "$prog: $_[0]\n" if ($_[0] && $_[0] ne "help");
+ print STDERR <<EOF;
+Usage: $prog [<options>] <existing-mailbox> <new-mailbox>
+ Options:
+ --debug turn on debugging
+ --help print this usage information
+ --host=<name> query host <name> instead of default POBOX server
+EOF
+ exit 1;
+}
+
+# Parse the command line arguments.
+use vars qw($opt_debug $opt_host);
+
+GetOptions("debug", "help" => \&usage, "host=s") || usage;
+
+usage "Please specify an existing and new mailbox names" if @ARGV != 2;
+
+my $username = $ENV{'ATHENA_USER'} || $ENV{'USER'} || getlogin || (getpwuid($<))[0] ||
+ errorout "Cannot determine user name";
+
+unless ($opt_host) {
+ $opt_host = (gethostbyname("$username.mail.mit.edu"))[0];
+ errorout "Cannot find Post Office server for $username" unless $opt_host;
+}
+errorout "Exchange accounts are not supported yet. Try http://owa.mit.edu/." if $opt_host =~ /EXCHANGE/;
+
+# Connect to the IMAP server, and authenticate.
+my $client = Cyrus::IMAP->new($opt_host) ||
+ errorout "Cannot connect to IMAP server on $opt_host";
+unless ($client->authenticate(-authz => $username, -maxssf => 0)) {
+ close_connection();
+ errorout "Cannot authenticate to $opt_host";
+}
+
+# Rename the mailbox.
+send_command "RENAME \"$ARGV[0]\" \"$ARGV[1]\"";
+
+# We are done talking to the IMAP server, close down the connection.
+close_connection();
+
+# Subroutine to send a command to the IMAP server, and wait for the
+# response; any defined callbacks for the response are invoked.
+# If the server response indicates failure, we error out.
+sub send_command($) {
+ print "Sending: $_[0]\n" if $opt_debug;
+ my ($status, $text) = $client->send('', '', $_[0]);
+ print "Response: status $status, text $text\n" if $opt_debug;
+ errorout "Premature end-of-file on IMAP connection to $opt_host"
+ if $status eq 'EOF';
+ if ($status ne 'OK') {
+ close_connection();
+ errorout "IMAP error on $opt_host: $text"
+ }
+}
+
+# Logout from the IMAP server, and close the connection.
+sub close_connection() {
+ $client->send('', '', "LOGOUT");
+ # Set the client reference to undef, so that perl invokes the
+ # destructor, which closes the connection. Note that if we invoke
+ # the destructor explicitly here, then perl will still invoke it
+ # again when the program exits, thus touching memory which has
+ # already been freed.
+ $client = undef;
+}
+
+sub errorout($) {
+ print STDERR "$prog: $_[0]\n";
+ exit 1;
+}
Copied: trunk/athena/bin/mitmailutils/bin/mitmailscan (from rev 25984, trunk/athena/bin/mitmailutils/mitmailscan.pl)
===================================================================
--- trunk/athena/bin/mitmailutils/bin/mitmailscan (rev 0)
+++ trunk/athena/bin/mitmailutils/bin/mitmailscan 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,413 @@
+#!/usr/bin/perl -w
+
+# $Id: mitmailscan.pl,v 1.5 2004-10-26 20:56:30 rbasch Exp $
+
+# Scan messages in an IMAP folder.
+
+use strict;
+use warnings FATAL => 'all';
+use Cyrus::IMAP;
+use Getopt::Long;
+
+sub usage(;$);
+sub send_command(@);
+sub search_callback(@);
+sub fetch_callback(@);
+sub number_callback(@);
+sub make_msgspecs(@);
+sub parse_date_opt($$);
+sub month_nametonum($);
+sub get_terminal_width();
+sub close_and_errorout($);
+sub close_connection();
+sub errorout($);
+
+my $prog = $0;
+
+sub usage(;$) {
+ print STDERR "$prog: $_[0]\n" if ($_[0] && $_[0] ne "help");
+ print STDERR <<EOF;
+Usage: $prog [<options>] [<message-id> ...]
+ Options:
+ --answered show messages which have been marked as answered
+ --before=<dd-Mon-yyyy> show messages sent before given date
+ --by-uid show message's unique ID instead of sequence number
+ --debug turn on debugging
+ --deleted show messages which have been marked as deleted
+ --from=<sender> show messages with <sender> in From field
+ --help print this usage information
+ --host=<name> query host <name> instead of default POBOX server
+ --id-only output message IDs only
+ --key=<string> same as --search-key=<string>
+ --larger=<n> show messages whose size is greater than <n> bytes
+ --mailbox=<name> examine mailbox <name> instead of INBOX
+ --new show new messages (same as "--recent --unseen")
+ --old show messages not marked as recent
+ --on=<dd-Mon-yyyy> show messages sent on given date
+ --recent show recent messages
+ --search-key=<string> specify explicit IMAP search key (see RFC 2060)
+ --seen show messages with the SEEN flag set
+ --since=<dd-Mon-yyyy> show messages sent since given date
+ --smaller=<n> show messages whose size is less than <n> bytes
+ --subject=<string> show messages with <string> in Subject field
+ --text=<string> show messages with <string> in header or body
+ --to=<recipient> show messages with <recipient> in To field
+ --unanswered show messages which have not been marked as answered
+ --undeleted show messages which have not been marked as deleted
+ --unseen show messages which do not have the SEEN flag set
+EOF
+ exit 1;
+}
+
+# Parse the command line.
+use vars qw($opt_answered $opt_before $opt_by_uid $opt_debug
+ $opt_deleted $opt_from $opt_host $opt_id_only
+ $opt_larger $opt_mailbox $opt_new $opt_old $opt_on
+ $opt_recent $opt_search_key $opt_seen $opt_since
+ $opt_smaller $opt_subject $opt_text $opt_to
+ $opt_unanswered $opt_undeleted $opt_unseen);
+
+# Map month names to numbers.
+my %monthnum = (
+ Jan => 1, Feb => 2, Mar => 3, Apr => 4, May => 5, Jun => 6,
+ Jul => 7, Aug => 8, Sep => 9, Oct => 10, Nov => 11, Dec => 12,
+);
+
+# Parse and validate the given date option string.
+# The first argument is the option name, and the second is the value.
+# We error out if the value is not of the form dd-Mon-yyyy. Otherwise,
+# we set the value of the corresponding $opt_<name> variable.
+sub parse_date_opt($$) {
+ # Disable strict refs locally so we can use a symbolic reference
+ # to set the appropriate $opt_<name> variable below.
+ no strict 'refs';
+ my ($name, $value) = @_;
+ usage "\"$value\" is not a valid date (dd-Mon-yyyy expected)"
+ unless (($value =~ m|^\d{1,2}-([A-Za-z]{3})-\d{4}$|o) &&
+ month_nametonum($1));
+ ${"opt_" . $name} = $value;
+}
+
+GetOptions("answered",
+ "before=s" => \&parse_date_opt,
+ "by-uid",
+ "debug",
+ "deleted",
+ "from=s",
+ "help" => \&usage,
+ "host=s",
+ "id-only",
+ "larger=i",
+ "mailbox=s",
+ "new",
+ "old",
+ "on=s" => \&parse_date_opt,
+ "recent",
+ "search-key|key=s",
+ "seen",
+ "since=s" => \&parse_date_opt,
+ "smaller=i",
+ "subject=s",
+ "text=s",
+ "to=s",
+ "unanswered",
+ "undeleted",
+ "unseen") || usage;
+
+my $msgset = '';
+foreach (@ARGV) {
+ errorout "Invalid message specification $_"
+ unless (m/^(?:\d+|\*)(?::(?:\d+|\*))?$/o);
+ $msgset .= ',' if $msgset;
+ $msgset .= "$_";
+}
+
+usage "Cannot specify both --new and --old" if ($opt_new && $opt_old);
+usage "Cannot specify both --recent and --old" if ($opt_recent && $opt_old);
+usage "Cannot specify both --seen and --unseen" if ($opt_seen && $opt_unseen);
+usage "Cannot specify both --deleted and --undeleted"
+ if ($opt_deleted && $opt_undeleted);
+
+$opt_mailbox = 'INBOX' unless $opt_mailbox;
+$opt_search_key = 'ALL' unless $opt_search_key;
+
+my $username = $ENV{'ATHENA_USER'} || $ENV{'USER'} || getlogin || (getpwuid($<))[0] ||
+ errorout "Cannot determine user name";
+
+unless ($opt_host) {
+ $opt_host = (gethostbyname("$username.mail.mit.edu"))[0];
+ errorout "Cannot find Post Office server for $username" unless $opt_host;
+}
+errorout "Exchange accounts are not supported yet. Try http://owa.mit.edu/." if $opt_host =~ /EXCHANGE/;
+
+# Build the search key based on the specified command line options.
+if ($msgset) {
+ $opt_search_key .= " UID" if $opt_by_uid;
+ $opt_search_key .= " $msgset";
+}
+$opt_search_key .= " FROM $opt_from" if $opt_from;
+$opt_search_key .= " SUBJECT $opt_subject" if $opt_subject;
+$opt_search_key .= " TO $opt_to" if $opt_to;
+$opt_search_key .= " TEXT $opt_text" if $opt_text;
+$opt_search_key .= " SENTBEFORE $opt_before" if $opt_before;
+$opt_search_key .= " SENTSINCE $opt_since" if $opt_since;
+$opt_search_key .= " SENTON $opt_on" if $opt_on;
+$opt_search_key .= " LARGER $opt_larger" if defined $opt_larger;
+$opt_search_key .= " SMALLER $opt_smaller" if defined $opt_smaller;
+$opt_search_key .= " NEW" if $opt_new;
+$opt_search_key .= " OLD" if $opt_old;
+$opt_search_key .= " RECENT" if $opt_recent;
+$opt_search_key .= " SEEN" if $opt_seen;
+$opt_search_key .= " UNSEEN" if $opt_unseen;
+$opt_search_key .= " ANSWERED" if $opt_answered;
+$opt_search_key .= " UNANSWERED" if $opt_unanswered;
+$opt_search_key .= " DELETED" if $opt_deleted;
+$opt_search_key .= " UNDELETED" if $opt_undeleted;
+
+# Connect to the IMAP server, and authenticate.
+my $client = Cyrus::IMAP->new($opt_host) ||
+ errorout "Cannot connect to IMAP server on $opt_host";
+$client->authenticate(-authz => $username, -maxssf => 0) ||
+ close_and_errorout "Cannot authenticate to $opt_host";
+
+# Examine the mailbox. This gives the numbers of existing messages,
+# as well as selecting the mailbox for read-only access.
+my $totalmsgcount = -1;
+my @msgids = ();
+my @pomsgs = ();
+my $cb_numbered = Cyrus::IMAP::CALLBACK_NUMBERED;
+$client->addcallback({-trigger => 'EXISTS', -flags => $cb_numbered,
+ -callback => \&number_callback,
+ -rock => \$totalmsgcount});
+send_command("EXAMINE %s", $opt_mailbox);
+
+if ($totalmsgcount) {
+ # Search the mailbox to obtain the desired message numbers.
+ $client->addcallback({-trigger => 'SEARCH',
+ -callback => \&search_callback,
+ -rock => \@msgids});
+ send_command("UID SEARCH %a", $opt_search_key);
+
+ # If there are messages of interest, fetch them.
+ if (@msgids > 0) {
+ #@msgids = sort {$a <=> $b} @msgids;
+ my $fetch = "FLAGS BODY.PEEK[HEADER.FIELDS (FROM SUBJECT DATE)]";
+ $client->addcallback({-trigger => 'FETCH', -flags => $cb_numbered,
+ -callback => \&fetch_callback,
+ -rock => \@pomsgs});
+ foreach (make_msgspecs(@msgids)) {
+ send_command("UID FETCH %a (%a)", $_, $fetch);
+ }
+ }
+}
+
+# We are done talking to the IMAP server; close down the connection.
+close_connection();
+
+# Quit now if there are no messages to display.
+exit 0 unless @pomsgs;
+
+# Display the message(s), sorted by the message ID (sequence number or UID).
+my $msg;
+my $id_key = ($opt_by_uid ? 'uid' : 'number');
+@pomsgs = sort { $a->{$id_key} <=> $b->{$id_key} } @pomsgs;
+if ($opt_id_only) {
+ # We are only outputting the message ID.
+ foreach $msg (@pomsgs) {
+ print "$msg->{$id_key} ";
+ }
+ print "\n";
+} else {
+ # Here for the standard formatted output.
+ my $id_width = length $pomsgs[$#pomsgs]->{$id_key};
+ my $tty_width = get_terminal_width();
+ my $from_width = 20;
+
+ # Calculate the line width remaining for the message subject.
+ # Allow for the ID, the flag character, date (mm/dd), and "From"
+ # field widths, plus 2 spaces between the fields.
+ my $subject_width = $tty_width - 1 -
+ ($id_width + 1 + 2 + 5 + 2 + $from_width + 2);
+ $subject_width = 0 if ($subject_width < 0);
+
+ # Construct the format string.
+ my $format = "%${id_width}s%s %02d/%02d %-${from_width}.${from_width}s" .
+ " %-${subject_width}.${subject_width}s\n";
+
+ # Loop to display each message.
+ foreach $msg (@pomsgs) {
+ my ($month, $day);
+ my $flag;
+
+ # Parse a date of the form "DD Mon ...", with an optional leading
+ # "Day, ", or of the form "MM/DD/YY...".
+ if ($msg->{date} =~ m|^\s*(?:...,\s+)?(\d{1,2})\s+([A-Za-z]{3})|o) {
+ # Parsed "DD Mon ...".
+ ($month, $day) = (month_nametonum($2), $1);
+ } elsif ($msg->{date} =~ m|^\s*(\d{1,2})/(\d{1,2})/\d+|o) {
+ # Parsed "MM/DD/YY...".
+ ($month, $day) = ($1, $2);
+ } else {
+ # Unrecognized date format.
+ ($month, $day) = (0, 0);
+ }
+
+ # Strip double quotes from the "From" header.
+ my $from = $msg->{from} || '';
+ $from =~ tr/"//d;
+
+ # Flag a deleted or unseen message.
+ if ($msg->{flags} =~ /\\Deleted\b/io) {
+ $flag = 'D';
+ } elsif ($msg->{flags} !~ /\\Seen\b/io) {
+ $flag = 'U';
+ } else {
+ $flag = ' ';
+ }
+
+ # Display the line.
+ printf($format, $msg->{$id_key}, $flag, int($month), int($day),
+ $from, $msg->{subject} ? $msg->{subject} : '');
+ }
+}
+
+# Subroutine to send a command to the IMAP server, and wait for the
+# response; any defined callbacks for the response are invoked.
+# If the server response indicates failure, we error out.
+sub send_command(@) {
+ my ($fmt, @args) = @_;
+ if ($opt_debug) {
+ local $" = ', ';
+ print "Send($fmt, @args) ...\n";
+ }
+ my ($status, $text) = $client->send('', '', $fmt, @args);
+ print "Response: status $status, text $text\n" if $opt_debug;
+ errorout "Premature end-of-file on IMAP connection to $opt_host"
+ if $status eq 'EOF';
+ close_and_errorout "IMAP error from $opt_host: $text"
+ if $status ne 'OK';
+}
+
+# Callback subroutine to parse the response from a SEARCH command.
+# The "-text" hash element contains the returned message numbers,
+# separated by a space. The "-rock" element is a reference to the
+# array in which to store the message numbers.
+sub search_callback(@) {
+ my %cb = @_;
+ print "In SEARCH callback: text $cb{-text}\n" if $opt_debug;
+ @{$cb{-rock}} = split(/\s/, $cb{-text});
+}
+
+# Callback subroutine to parse the response from a FETCH command.
+# This callback will be invoked for each message. The "-text" hash
+# element contains the text returned by the server. The "-rock"
+# element is a reference to the array in which to push a hash of the
+# various message data items.
+sub fetch_callback(@) {
+ my %cb = @_;
+ my ($number, $uid, $flags, $from, $to, $subject, $date);
+ print "In FETCH callback: msgno $cb{-msgno} text $cb{-text}\n"
+ if $opt_debug;
+ $number = $cb{-msgno};
+ my @response_lines = split /\r\n/, $cb{-text};
+ $_ = shift @response_lines;
+ $uid = $1 if /\bUID\s+(\d+)/io;
+ $flags = $1 if /\bFLAGS\s+\(([^\)]*)\)/io;
+ foreach (@response_lines) {
+ $from = $_ if s/^From:\s*//io;
+ $to = $_ if s/^To:\s*//io;
+ $subject = $_ if s/^Subject:\s*//io;
+ $date = $_ if s/^Date:\s*//io;
+ }
+ push @{$cb{-rock}}, {number => $number, uid => $uid, flags => $flags,
+ from => $from, to => $to, subject => $subject,
+ date => $date}
+ if $number;
+}
+
+# Callback subroutine to parse a numeric value. The "-rock" hash
+# element is a reference to the scalar in which to store the number.
+sub number_callback(@) {
+ my %cb = @_;
+ print "In number callback: keyword $cb{-keyword}, number $cb{-msgno}\n"
+ if $opt_debug;
+ ${$cb{-rock}} = $cb{-msgno};
+}
+
+# This subroutine takes a list of IMAP message sequence or UID
+# numbers, and constructs single-string representations of the set,
+# collapsing sequences into ranges where possible. In order to avoid
+# constructing a specification which is too long to be processed, the
+# result is returned as an array of manageably-sized specification
+# strings, currently limited to about 200 characters each.
+sub make_msgspecs(@) {
+ return '' if @_ == 0;
+ my @specs = ();
+ my $first = shift(@_);
+ my $last = $first;
+ my $spec = $first;
+ foreach (@_) {
+ if ($_ != $last + 1) {
+ # This number is not in sequence with the previous element.
+ # If that marks the end of a range, complete it.
+ $spec .= ":$last" if ($first != $last);
+ # Begin a new sequence. Create another spec string if the
+ # current one is getting long.
+ if (length($spec) > 200) {
+ push @specs, $spec;
+ $spec = $_;
+ } else {
+ $spec .= ",$_";
+ }
+ $first = $_;
+ }
+ $last = $_;
+ }
+ # Complete the final range if necessary.
+ $spec .= ":$last" if ($first != $last);
+ push @specs, $spec if ($spec);
+ return @specs;
+}
+
+# Convert month names to numbers.
+sub month_nametonum($) {
+ my $num = $monthnum{ucfirst(lc($_[0]))};
+ return ($num ? $num : 0);
+}
+
+# Return the terminal line width. Unfortunately, the only feasible
+# way to get the width is to parse stty output.
+sub get_terminal_width() {
+ my $columns = 80;
+ open STTY, "stty -a |" or return $columns;
+ while (<STTY>) {
+ if (/columns[\s=]+(\d+);/o) {
+ $columns = $1;
+ last;
+ }
+ }
+ close STTY;
+ return $columns;
+}
+
+# Close the connection to the IMAP server, and error out.
+sub close_and_errorout($) {
+ close_connection();
+ errorout $_[0];
+}
+
+# Logout from the IMAP server, and close the connection.
+sub close_connection() {
+ $client->send('', '', "LOGOUT");
+ # Set the client reference to undef, so that perl invokes the
+ # destructor, which closes the connection. Note that if we invoke
+ # the destructor explicitly here, then perl will still invoke it
+ # again when the program exits, thus touching memory which has
+ # already been freed.
+ $client = undef;
+}
+
+sub errorout($) {
+ print STDERR "$prog: $_[0]\n";
+ exit 1;
+}
Copied: trunk/athena/bin/mitmailutils/bin/mitmailshow (from rev 25984, trunk/athena/bin/mitmailutils/mitmailshow.pl)
===================================================================
--- trunk/athena/bin/mitmailutils/bin/mitmailshow (rev 0)
+++ trunk/athena/bin/mitmailutils/bin/mitmailshow 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,166 @@
+#!/usr/bin/perl -w
+
+# $Id: mitmailshow.pl,v 1.3 2004-07-29 19:11:54 rbasch Exp $
+
+# Show messages in an IMAP folder.
+
+use strict;
+use warnings FATAL => 'all';
+use Cyrus::IMAP;
+use Getopt::Long;
+
+sub usage(;$);
+sub send_command($);
+sub fetch_callback(@);
+sub number_callback(@);
+sub close_and_errorout($);
+sub close_connection();
+sub errorout($);
+
+my $prog = $0;
+
+sub usage(;$) {
+ print STDERR "$prog: $_[0]\n" if ($_[0] && $_[0] ne "help");
+ print STDERR <<EOF;
+Usage: $prog [<options>] <message-ID> [...]
+ Options:
+ --by-uid specify message's unique ID, not sequence number
+ --debug turn on debugging
+ --help print this usage information
+ --host=<name> query host <name> instead of default POBOX server
+ --mailbox=<name> access mailbox <name> instead of INBOX
+ --no-mark do not mark the message as having been seen
+ --peek same as --no-mark
+EOF
+ exit 1;
+}
+
+# Parse the command line arguments.
+use vars qw($opt_by_uid $opt_debug $opt_expunge $opt_host $opt_mailbox
+ $opt_no_mark);
+
+GetOptions("by-uid",
+ "debug",
+ "help" => \&usage,
+ "host=s",
+ "mailbox=s",
+ "no-mark|peek") || usage;
+
+usage "Please specify a message ID" if @ARGV == 0;
+
+# Check the validity of message ID arguments.
+# The ID can be a number or '*', and we accept a range specification,
+# of the form 'n:m'.
+foreach (@ARGV) {
+ errorout "Invalid message specification $_"
+ unless (m/^(?:\d+|\*)(?::(?:\d+|\*))?$/o);
+}
+
+$opt_mailbox = "INBOX" unless $opt_mailbox;
+
+my $username = $ENV{'ATHENA_USER'} || $ENV{'USER'} || getlogin || (getpwuid($<))[0] ||
+ errorout "Cannot determine user name";
+
+unless ($opt_host) {
+ $opt_host = (gethostbyname("$username.mail.mit.edu"))[0];
+ errorout "Cannot find Post Office server for $username" unless $opt_host;
+}
+errorout "Exchange accounts are not supported yet. Try http://owa.mit.edu/." if $opt_host =~ /EXCHANGE/;
+
+# Connect to the IMAP server, and authenticate.
+my $client = Cyrus::IMAP->new($opt_host) ||
+ errorout "Cannot connect to IMAP server on $opt_host";
+$client->authenticate(-authz => $username, -maxssf => 0) ||
+ close_and_errorout "Cannot authenticate to $opt_host";
+
+# Select (or examine, if in no-mark mode) the mailbox.
+my $select_cmd = ($opt_no_mark ? 'EXAMINE' : 'SELECT');
+send_command "$select_cmd \"$opt_mailbox\"";
+
+# Fetch the messages. The message body will be displayed by the
+# fetch_callback subroutine.
+my $cb_numbered = Cyrus::IMAP::CALLBACK_NUMBERED;
+my $fetch_cmd = ($opt_by_uid ? 'UID FETCH' : 'FETCH');
+my $fetch = ($opt_no_mark ? 'BODY.PEEK[]' : 'BODY[]');
+$client->addcallback({-trigger => 'FETCH', -flags => $cb_numbered,
+ -callback => \&fetch_callback});
+my $exitcode = 0;
+foreach (@ARGV) {
+ my ($status, $text) = send_command "$fetch_cmd $_ ($fetch)";
+ if ($status ne 'OK') {
+ print STDERR "$prog: Cannot fetch $_: $text\n";
+ $exitcode = 1;
+ }
+}
+
+# We are done talking to the IMAP server, close down the connection.
+close_connection();
+
+exit $exitcode;
+
+# Subroutine to send a command to the IMAP server, and wait for the
+# response; any defined callbacks for the response are invoked.
+# If called in list context, the response status and text strings
+# are returned; otherwise, if the status indicates failure (i.e. is
+# not "OK"), we error out.
+sub send_command($) {
+ print "Sending: $_[0]\n" if $opt_debug;
+ my ($status, $text) = $client->send('', '', $_[0]);
+ print "Response: status $status, text $text\n" if $opt_debug;
+ errorout "Premature end-of-file on IMAP connection to $opt_host"
+ if $status eq 'EOF';
+ return ($status, $text) if wantarray;
+ close_and_errorout "IMAP error from $opt_host: $text"
+ if $status ne 'OK';
+}
+
+# Callback subroutine to parse the response from a FETCH command,
+# and display the message body on standard output. The body text
+# is converted to Unix-style end-of-line, but is otherwise unfiltered.
+# This callback will be invoked for each message. The "-text" hash
+# element contains the text returned by the server.
+sub fetch_callback(@) {
+ my %cb = @_;
+ print "In FETCH callback: msgno $cb{-msgno} text $cb{-text}\n"
+ if $opt_debug;
+ $_ = $cb{-text};
+ # Extract the body size, and strip off the response up to the body.
+ my $size = $1 if s/.*?BODY\[\] \{(\d+)\}\r\n//ios;
+ return unless $size;
+ # Extract the body text.
+ $_ = substr($_, 0, $size);
+ # Convert to Unix-style EOL.
+ s/\r\n/\n/gos;
+ print $_;
+}
+
+# Callback subroutine to parse a numeric value. The "-rock" hash
+# element is a reference to the scalar in which to store the number.
+sub number_callback(@) {
+ my %cb = @_;
+ print "In number callback: keyword $cb{-keyword}, number $cb{-msgno}\n"
+ if $opt_debug;
+ ${$cb{-rock}} = $cb{-msgno};
+}
+
+# Close the connection to the IMAP server, and error out.
+sub close_and_errorout($) {
+ close_connection();
+ errorout $_[0];
+}
+
+# Logout from the IMAP server, and close the connection.
+sub close_connection() {
+ $client->send('', '', "LOGOUT");
+ # Set the client reference to undef, so that perl invokes the
+ # destructor, which closes the connection. Note that if we invoke
+ # the destructor explicitly here, then perl will still invoke it
+ # again when the program exits, thus touching memory which has
+ # already been freed.
+ $client = undef;
+}
+
+sub errorout($) {
+ print STDERR "$prog: $_[0]\n";
+ exit 1;
+}
Modified: trunk/athena/bin/mitmailutils/debian/changelog
===================================================================
--- trunk/athena/bin/mitmailutils/debian/changelog 2013-05-11 22:19:43 UTC (rev 25984)
+++ trunk/athena/bin/mitmailutils/debian/changelog 2013-05-12 06:24:44 UTC (rev 25985)
@@ -1,10 +1,17 @@
-debathena-mitmailutils (10.1.3-0debathena2) UNRELEASED; urgency=low
+debathena-mitmailutils (10.1.4-0debathena1) UNRELEASED; urgency=low
+ [ Jonathan Reed ]
* Bump debian/compat to 6
* Switch from control.in to control (Trac: #561)
* Bump Standards-Version to 3.9.3
* Bump compat level to 7
+ [ Victor Vasiliev ]
+ * Use debhelper7
+ * Create bin/ and man/ directories for organization purposes
+ * Bump upstream version
+ * Switch to source format 3.0 (quilt)
+
-- Jonathan Reed <jdreed@mit.edu> Wed, 03 Apr 2013 13:59:52 -0400
debathena-mitmailutils (10.1.3-0debathena1) unstable; urgency=low
Modified: trunk/athena/bin/mitmailutils/debian/control
===================================================================
--- trunk/athena/bin/mitmailutils/debian/control 2013-05-11 22:19:43 UTC (rev 25984)
+++ trunk/athena/bin/mitmailutils/debian/control 2013-05-12 06:24:44 UTC (rev 25985)
@@ -2,7 +2,7 @@
Section: debathena/mail
Priority: extra
Maintainer: Debathena Project <debathena@mit.edu>
-Build-Depends: cdbs, debhelper, dh-buildinfo, autoconf
+Build-Depends: debhelper (>= 7)
Standards-Version: 3.9.3
Package: debathena-mitmailutils
@@ -14,7 +14,7 @@
debathena-mitmailcreate, debathena-mitmaildel, debathena-mitmailexp,
debathena-mitmailmove, debathena-mitmailrename,
debathena-mitmailscan, debathena-mitmailshow
-Depends: ${shlibs:Depends}, ${misc:Depends}, libcyrus-imap-perl22 | debathena-libcyrus-imap-perl, libsasl2-modules-gssapi-mit, hesiod
+Depends: ${perl:Depends}, ${misc:Depends}, libcyrus-imap-perl22 | debathena-libcyrus-imap-perl, libsasl2-modules-gssapi-mit, hesiod
Replaces: debathena-from, debathena-mailquota, debathena-mailusage,
debathena-mitmailappend, debathena-mitmailcreate,
debathena-mitmaildel, debathena-mitmailexp, debathena-mitmailmove,
Modified: trunk/athena/bin/mitmailutils/debian/rules
===================================================================
--- trunk/athena/bin/mitmailutils/debian/rules 2013-05-11 22:19:43 UTC (rev 25984)
+++ trunk/athena/bin/mitmailutils/debian/rules 2013-05-12 06:24:44 UTC (rev 25985)
@@ -1,13 +1,5 @@
#!/usr/bin/make -f
-DEB_AUTO_UPDATE_AUTOCONF = 2.50
-include /usr/share/cdbs/1/rules/debhelper.mk
-include /usr/share/cdbs/1/class/autotools.mk
+%:
+ dh $@
-common-install-impl::
- mv $(DEB_DESTDIR)/usr/bin/from $(DEB_DESTDIR)/usr/bin/from.debathena
- mv $(DEB_DESTDIR)/usr/share/man/man1/from.1 \
- $(DEB_DESTDIR)/usr/share/man/man1/from.debathena.1
-
-clean::
- rm -f configure
Added: trunk/athena/bin/mitmailutils/debian/source/format
===================================================================
--- trunk/athena/bin/mitmailutils/debian/source/format (rev 0)
+++ trunk/athena/bin/mitmailutils/debian/source/format 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1 @@
+3.0 (quilt)
Copied: trunk/athena/bin/mitmailutils/man/from.1 (from rev 25984, trunk/athena/bin/mitmailutils/from.1)
===================================================================
--- trunk/athena/bin/mitmailutils/man/from.1 (rev 0)
+++ trunk/athena/bin/mitmailutils/man/from.1 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,112 @@
+.\"
+.\" $Id: from.1,v 1.8 2003-10-06 21:09:56 rbasch Exp $
+.\"
+.TH FROM 1
+.DA June 30, 1991
+.UC 4
+.SH NAME
+from \- who is my mail from?
+.SH SYNOPSIS
+.B from
+[
+.BR \-s " sender"
+] [
+.BR \-h " host"
+] [
+.BR \-m " mailbox"
+] [
+.BR \-A " | " \-N "
+] [
+.BR \-v " | " \-r " | " \-t
+] [
+.B \-d
+] [
+.B \-u
+|
+.B \-p
+] [
+.B \-?
+] [ user ]
+.SH DESCRIPTION
+The
+.I from
+program prints out the mail header lines in your incoming mail
+to show you who your mail is from. It does this by looking for mail
+in the local spool directory and then checking for mail marked as
+unseen on the post office server. This command does not retrieve the
+mail from the post office or the spool directory.
+
+If no mail is waiting,
+.I from
+is silent unless one of
+.BR -v ", " -r ", or " -t
+is used, in which case it prints "You don't have any mail waiting."
+If the
+.B -n
+option is used,
+.I from
+is always silent if there is no mail.
+
+.I from
+understands the following options:
+.TP
+.B \-s \fIsender\fR
+specifies that only headers for mail from
+.I sender
+are printed.
+.TP
+.B \-h \fIhost\fR
+specifies that
+.I host
+should be consulted instead of your default post office server.
+.TP
+.B \-m \fImailbox\fR
+specifies that the IMAP folder named
+.I mailbox
+should be checked. For example, to check your MIT spam screening folder,
+specify \fI-m INBOX.Spamscreen\fR. If this option is not specified,
+.I from
+checks the INBOX folder.
+.TP
+.B \-A
+specifies that all messages in the IMAP mailbox should be checked,
+instead of only unseen messages.
+.TP
+.B \-N
+specifies that only messages marked as new in the IMAP mailbox should
+be checked, instead of unseen messages.
+.TP
+.B \-v
+specifies that any To, Date, or Subject fields should be displayed
+also, as well as a banner line list the number of messages waiting.
+.TP
+.B \-r
+specifies that the From and Subject fields should be listed both on
+the same line. If multiple subject fields occur in the message only
+the first one encounter will be listed.
+.TP
+.B \-t
+specifies that only the total number of messages waiting should be
+printed.
+.TP
+.B \-d
+specifies that
+.I from
+should run in debug mode.
+.TP
+.B \-u
+specifies that only the local mail drop should be checked.
+.TP
+.B \-p
+specifies that only the post office server should be checked.
+.TP
+.B \-?
+specifies that usage information should be printed, no mail check
+occurs.
+.TP
+.B \fIuser\fR
+specifies that mail for
+.I user
+should be checked, rather than the current user.
+.SH "SEE ALSO"
+imtest(1), RFC\-2060 (Internet Message Access Protocol - Version 4rev1)
Copied: trunk/athena/bin/mitmailutils/man/mailquota.1 (from rev 25984, trunk/athena/bin/mitmailutils/mailquota.1)
===================================================================
--- trunk/athena/bin/mitmailutils/man/mailquota.1 (rev 0)
+++ trunk/athena/bin/mitmailutils/man/mailquota.1 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,74 @@
+.\"
+.\" $Id: mailquota.1,v 1.1 2003-10-10 21:30:45 rbasch Exp $
+.\"
+.TH MAILQUOTA 1
+.UC 4
+.SH NAME
+mailquota \- display post office resource usage and limits
+.SH SYNOPSIS
+.B mailquota
+[
+.BR \-h " host"
+] [
+.BR \-m " mailbox"
+] [
+.B \-n
+] [
+.B \-u " percent"
+] [
+.B \-d
+] [ user ]
+.SH DESCRIPTION
+The
+.I mailquota
+program displays a user's mail resource usage and limits on the post
+office server. Quota resources which are displayed, if defined on
+the server, are storage (in kilobytes) and number of messages.
+
+.I mailquota
+understands the following options:
+.TP
+.B \-h \fIhost\fR
+specifies that
+.I host
+should be consulted instead of your default post office server.
+.TP
+.B \-m \fImailbox\fR
+specifies that the quota for the IMAP folder named
+.I mailbox
+should be checked. If this option is not specified,
+.I mailquota
+checks the quota for the INBOX folder. (For MIT post office servers,
+the quota applies to the entire INBOX folder hierarchy, so there
+is no need to check other mailboxes).
+.TP
+.B \-n
+specifies that
+.I mailquota
+should only display a quota when any resource usage is above a
+percentage threshold; that threshold's default value is 90, but may be
+set via the
+.B -u
+option.
+.TP
+.B \-u \fIpercent\fR
+specifies the usage percentage threshold. A defined quota whose
+resource usages are below this threshold will not be displayed.
+Specifying this option implies the
+.B -n
+option; if
+.B -n
+is specified, and this option is not specified, the default usage
+threshold is 90.
+.TP
+.B \-d
+specifies that
+.I mailquota
+should run in debug mode.
+.TP
+.B \fIuser\fR
+specifies that the mail quota for
+.I user
+should be checked, rather than the current user.
+.SH "SEE ALSO"
+imtest(1), RFC\-2087 (IMAP4 QUOTA extension)
Copied: trunk/athena/bin/mitmailutils/man/mailusage.1 (from rev 25984, trunk/athena/bin/mitmailutils/mailusage.1)
===================================================================
--- trunk/athena/bin/mitmailutils/man/mailusage.1 (rev 0)
+++ trunk/athena/bin/mitmailutils/man/mailusage.1 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,80 @@
+.\"
+.\" $Id: mailusage.1,v 1.1 2003-11-26 00:26:32 rbasch Exp $
+.\"
+.TH MAILUSAGE 1
+.SH NAME
+mailusage \- display size of mail folders on a post office server
+.SH SYNOPSIS
+.B mailusage
+[
+.B \-h " host"
+] [
+.B \-m " mailbox"
+] [
+.B \-n
+] [
+.B \-r
+] [
+.B \-s
+] [
+.B \-d
+] [ user ]
+.SH DESCRIPTION
+The
+.I mailusage
+program displays the total size of, and number of messages in, the
+user's mail folders on a post office server. Size is displayed in
+kilobytes. With no options specified, all of the user's mailboxes on
+the server will be listed.
+
+.I mailusage
+understands the following options:
+.TP
+.B \-h \fIhost\fR
+specifies that
+.I host
+should be consulted instead of the user's default post office server.
+.TP
+.B \-m \fImailbox\fR
+specifies that only the usage for
+.I mailbox
+should be displayed. If this option is not specified,
+.I mailusage
+displays usage for all of the user's mailboxes on the server. Use the
+.B \-r
+option in conjunction with
+.B \-m
+to display the usage for a mailbox and all of its descendents.
+.TP
+.B \-n
+specifies that
+.I mailusage
+should not output a header line. This is useful if the output will be
+parsed by another program.
+.TP
+.B \-r
+specifies that
+.I mailusage
+should display usage recursively for a given mailbox, i.e. by listing
+all of the mailbox's descendents. This option is only useful in
+conjunction with the
+.B \-m \fImailbox\fR
+option.
+.TP
+.B \-s
+specifies that
+.I mailusage
+should only display usage for mailboxes to which the user has subscribed.
+.TP
+.B \-d
+specifies that
+.I mailusage
+should run in debug mode.
+.TP
+.B \fIuser\fR
+specifies that the mail usage for
+.I user
+should be checked, rather than the current user.
+.SH "SEE ALSO"
+mailquota(1), imtest(1),
+RFC\-2060 (Internet Message Access Protocol - Version 4rev1)
Copied: trunk/athena/bin/mitmailutils/man/mitmailappend.1 (from rev 25984, trunk/athena/bin/mitmailutils/mitmailappend.1)
===================================================================
--- trunk/athena/bin/mitmailutils/man/mitmailappend.1 (rev 0)
+++ trunk/athena/bin/mitmailutils/man/mitmailappend.1 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,58 @@
+.\"
+.\" $Id: mitmailappend.1,v 1.1 2004-09-03 20:44:43 rbasch Exp $
+.\"
+.TH MITMAILAPPEND 1
+.SH NAME
+mitmailappend \- append a message to an IMAP folder
+.SH SYNOPSIS
+.B mitmailappend
+[
+.B \--debug
+] [
+.B \--file
+.I path
+] [
+.B \--help
+] [
+.B \--host
+.I name
+] [
+.B \--mailbox
+.I name
+] [
+.B \--no-create
+]
+.SH DESCRIPTION
+The
+.I mitmailappend
+program appends one message to a folder on an IMAP server. The message
+text is read from standard input, or, if the
+.B \--file
+option is specified, from the given path value.
+.SH OPTIONS
+.I mitmailappend
+understands the following options:
+.TP
+.B \--debug
+turn on debugging.
+.TP
+.B \--file \fIpath\fR
+read the message text from the file \fIpath\fR, instead of from
+standard input.
+.TP
+.B \--help
+display usage information and exit.
+.TP
+.B \--host \fIname\fR
+query the given host, instead of the default post office server.
+.TP
+.B \--mailbox \fIname\fR
+append the message to the IMAP folder \fIname\fR. If this option is
+not specified, the message is appended to the INBOX folder.
+.TP
+.B \--no-create
+do not create the target mailbox automatically. By default, the target
+mailbox will be created automatically if necessary.
+.SH "SEE ALSO"
+mitmailscan(1), mitmailshow(1), mitmaildel(1), mitmailcreate(1)
+imtest(1), RFC\-2060 (Internet Message Access Protocol - Version 4rev1)
Copied: trunk/athena/bin/mitmailutils/man/mitmailcreate.1 (from rev 25984, trunk/athena/bin/mitmailutils/mitmailcreate.1)
===================================================================
--- trunk/athena/bin/mitmailutils/man/mitmailcreate.1 (rev 0)
+++ trunk/athena/bin/mitmailutils/man/mitmailcreate.1 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,49 @@
+.\"
+.\" $Id: mitmailcreate.1,v 1.1 2004-06-28 19:34:34 rbasch Exp $
+.\"
+.TH MITMAILCREATE 1
+.SH NAME
+mitmailcreate, mitmailremove, mitmailsubscribe, mitmailunsubscribe \- create, delete, or subscribe or unsubscribe to IMAP mailboxes
+.SH SYNOPSIS
+.B mitmailcreate | mitmailremove | mitmailsubscribe | mitmailunsubscribe
+[
+.B \--debug
+] [
+.B \--help
+] [
+.B \--host
+.I name
+] [
+.B \--mailbox
+.I name
+] [
+.B \--no-subscribe
+]
+.I mailbox [ ... ]
+.SH DESCRIPTION
+The \fImitmailcreate\fR and \fImitmailremove\fR commands can be used to
+create or delete mailboxes on an IMAP server, respectively. The
+\fImitmailsubscribe\fR and \fImitmailunsubscribe\fR commands can be used
+to subscribe or unsubscribe to mailboxes, respectively.
+.SH OPTIONS
+These commands understand the following options:
+.TP
+.B \--debug
+turn on debugging.
+.TP
+.B \--help
+display usage information and exit.
+.TP
+.B \--host \fIname\fR
+query the given host, instead of the default post office server.
+.TP
+\fImitmailcreate\fR understands the following additional option:
+.TP
+.B \--no-subscribe
+do not subscribe to the newly created mailbox. By default, the new
+mailbox will be subscribed to automatically.
+.SH ARGUMENTS
+These commands require one or more mailbox name arguments to be given.
+.SH "SEE ALSO"
+mailusage(1), mitmailexp(1),
+imtest(1), RFC\-2060 (Internet Message Access Protocol - Version 4rev1)
Copied: trunk/athena/bin/mitmailutils/man/mitmaildel.1 (from rev 25984, trunk/athena/bin/mitmailutils/mitmaildel.1)
===================================================================
--- trunk/athena/bin/mitmailutils/man/mitmaildel.1 (rev 0)
+++ trunk/athena/bin/mitmailutils/man/mitmaildel.1 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,93 @@
+.\"
+.\" $Id: mitmaildel.1,v 1.1 2004-01-21 23:15:10 rbasch Exp $
+.\"
+.TH MITMAILDEL 1
+.SH NAME
+mitmaildel, mitmailundel \- delete or undelete messages in an IMAP folder
+.SH SYNOPSIS
+.B mitmaildel | mitmailundel
+[
+.B \--by-uid
+] [
+.B \--debug
+] [
+.B \--expunge
+] [
+.B \--help
+] [
+.B \--host
+.I name
+] [
+.B \--mailbox
+.I name
+] [
+.B \--silent
+]
+.I message-ID
+[ ... ]
+.SH DESCRIPTION
+The
+.I mitmaildel
+program
+marks the specified messages for deletion from a folder on an IMAP
+server. If the
+.B \--expunge
+option is given, all deleted messages are permanently removed from the
+mailbox; otherwise, messages marked for deletion remain in the mailbox.
+
+The
+.I mitmailundel
+command unmarks the specified messages for deletion.
+.SH OPTIONS
+.I mitmaildel
+and
+.I mitmailundel
+understand the following options:
+.TP
+.B \--by-uid
+specify that the given message ID arguments are unique identifiers, not
+sequence numbers.
+.TP
+.B \--debug
+turn on debugging.
+.TP
+.B \--epxunge
+expunge the maibox after marking (or unmarking) the specified messages,
+permanently removing all deleted messages. This option should be used
+with caution, as the message sequence numbers change upon an expunge;
+when performing multiple invocations of \fImitmaildel\fR, it is best to
+expunge the mailbox only once, with \fImitmailexp(1)\fR, after marking
+messages as desired.
+.TP
+.B \--help
+display usage information and exit.
+.TP
+.B \--host \fIname\fR
+query the given host, instead of the default post office server.
+.TP
+.B \--mailbox \fIname\fR
+mark messages in the IMAP folder \fIname\fR. If this option is
+not specified, messages in the INBOX folder are marked.
+.TP
+.B \--silent
+do not display an acknowledgement. If this option is not specified,
+an acknowledgement for each specified message that is marked is
+displayed on standard output.
+.SH ARGUMENTS
+.I mitmaildel
+and
+.I mitmailundel
+require one or more message ID arguments to be given. The ID is
+either the message's sequence number, or, if the
+.I \--by-uid
+option is given, its unique identifier.
+.I mitmailscan(1)
+can be used to obtain the message ID.
+
+The message ID argument can be \fB*\fR, to indicate the last message
+in the mailbox. An argument of the form
+.IB ID1 : ID2
+can be used to specify a range of IDs.
+.SH "SEE ALSO"
+mitmailscan(1), mitmailexp(1), mitmailshow(1),
+imtest(1), RFC\-2060 (Internet Message Access Protocol - Version 4rev1)
Copied: trunk/athena/bin/mitmailutils/man/mitmailexp.1 (from rev 25984, trunk/athena/bin/mitmailutils/mitmailexp.1)
===================================================================
--- trunk/athena/bin/mitmailutils/man/mitmailexp.1 (rev 0)
+++ trunk/athena/bin/mitmailutils/man/mitmailexp.1 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,44 @@
+.\"
+.\" $Id: mitmailexp.1,v 1.1 2004-01-21 23:17:19 rbasch Exp $
+.\"
+.TH MITMAILEXP 1
+.SH NAME
+mitmailexp \- expunge deleted messages from an IMAP folder
+.SH SYNOPSIS
+.B mitmailexp
+[
+.B \--debug
+] [
+.B \--help
+] [
+.B \--host
+.I name
+] [
+.B \--mailbox
+.I name
+]
+.SH DESCRIPTION
+The
+.I mitmailexp
+program
+expunges all of the messages which have been marked for deletion from
+a mailbox on an IMAP server.
+.SH OPTIONS
+.I mitmailexp
+understands the following options:
+.TP
+.B \--debug
+turn on debugging.
+.TP
+.B \--help
+display usage information and exit.
+.TP
+.B \--host \fIname\fR
+query the given host, instead of the default post office server.
+.TP
+.B \--mailbox \fIname\fR
+expunge deleted messages from the IMAP folder \fIname\fR. If this
+option is not specified, messages in the INBOX folder are expunged.
+.SH "SEE ALSO"
+mitmaildel(1), mitmailscan(1), mitmailshow(1),
+imtest(1), RFC\-2060 (Internet Message Access Protocol - Version 4rev1)
Copied: trunk/athena/bin/mitmailutils/man/mitmailmove.1 (from rev 25984, trunk/athena/bin/mitmailutils/mitmailmove.1)
===================================================================
--- trunk/athena/bin/mitmailutils/man/mitmailmove.1 (rev 0)
+++ trunk/athena/bin/mitmailutils/man/mitmailmove.1 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,85 @@
+.\"
+.\" $Id: mitmailmove.1,v 1.1 2004-06-07 19:13:53 rbasch Exp $
+.\"
+.TH MITMAILMOVE 1
+.SH NAME
+mitmailmove, mitmailcopy \- move or copy messages between IMAP folders
+.SH SYNOPSIS
+.B mitmailmove | mitmailcopy
+[
+.B \--by-uid
+] [
+.B \--debug
+] [
+.B \--help
+] [
+.B \--host
+.I name
+] [
+.B \--mailbox
+.I name
+] [
+.B \--no-create
+]
+.I message-ID
+[ ... ]
+.I target-mailbox
+.SH DESCRIPTION
+The
+.I mitmailmove
+program
+copies the specified messages from one folder to another on an IMAP server,
+and then marks the original messages for deletion.
+
+The
+.I mitmailcopy
+command performs only the copy operation.
+.SH OPTIONS
+.I mitmailmove
+and
+.I mitmailcopy
+understand the following options:
+.TP
+.B \--by-uid
+specify that the given message ID arguments are unique identifiers, not
+sequence numbers.
+.TP
+.B \--debug
+turn on debugging.
+.TP
+.B \--help
+display usage information and exit.
+.TP
+.B \--host \fIname\fR
+query the given host, instead of the default post office server.
+.TP
+.B \--mailbox \fIname\fR
+move or copy messages from the IMAP folder \fIname\fR. If this option is
+not specified, messages are moved or copied from the INBOX folder.
+.TP
+.B \--no-create
+do not create the target mailbox automatically. By default, the target
+mailbox will be created automatically if necessary.
+.SH ARGUMENTS
+.I mitmailmove
+and
+.I mitmailcopy
+require one or more message ID arguments to be given. The ID is
+either the message's sequence number, or, if the
+.I \--by-uid
+option is given, its unique identifier.
+.I mitmailscan(1)
+can be used to obtain the message ID.
+
+The message ID argument can be \fB*\fR, to indicate the last message
+in the mailbox. An argument of the form
+.IB ID1 : ID2
+can be used to specify a range of IDs.
+
+The final argument on the command line is taken as the target mailbox
+name. Unless the
+.I \--no-create
+option is given, this mailbox will be created automatically if necessary.
+.SH "SEE ALSO"
+mitmailscan(1), mitmaildel(1), mitmailexp(1),
+imtest(1), RFC\-2060 (Internet Message Access Protocol - Version 4rev1)
Copied: trunk/athena/bin/mitmailutils/man/mitmailrename.1 (from rev 25984, trunk/athena/bin/mitmailutils/mitmailrename.1)
===================================================================
--- trunk/athena/bin/mitmailutils/man/mitmailrename.1 (rev 0)
+++ trunk/athena/bin/mitmailutils/man/mitmailrename.1 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,39 @@
+.\"
+.\" $Id: mitmailrename.1,v 1.1 2004-06-30 17:52:05 rbasch Exp $
+.\"
+.TH MITMAILRENAME 1
+.SH NAME
+mitmailrename \- rename an IMAP mailbox
+.SH SYNOPSIS
+.B mitmailrename
+[
+.B \--debug
+] [
+.B \--help
+] [
+.B \--host
+.I name
+]
+.I existing-mailbox new-mailbox
+.SH DESCRIPTION
+The \fImitmailrename\fR command changes the name of a mailbox on an
+IMAP server.
+.SH OPTIONS
+The
+.I mitmailrename
+command understands the following options:
+.TP
+.B \--debug
+turn on debugging.
+.TP
+.B \--help
+display usage information and exit.
+.TP
+.B \--host \fIname\fR
+query the given host, instead of the default post office server.
+.SH ARGUMENTS
+.I mitmailrename
+requires the name of an existing mailbox and a new mailbox name as arguments.
+.SH "SEE ALSO"
+mitmailcreate(1), mitmailremove(1), mailusage(1),
+imtest(1), RFC\-2060 (Internet Message Access Protocol - Version 4rev1)
Copied: trunk/athena/bin/mitmailutils/man/mitmailscan.1 (from rev 25984, trunk/athena/bin/mitmailutils/mitmailscan.1)
===================================================================
--- trunk/athena/bin/mitmailutils/man/mitmailscan.1 (rev 0)
+++ trunk/athena/bin/mitmailutils/man/mitmailscan.1 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,201 @@
+.\"
+.\" $Id: mitmailscan.1,v 1.2 2004-09-10 16:35:44 rbasch Exp $
+.\"
+.TH MITMAILSCAN 1
+.SH NAME
+mitmailscan \- scan messages in an IMAP folder
+.SH SYNOPSIS
+.B mitmailscan
+[
+.B \--answered
+] [
+.B \--before
+.I dd-Mon-yyyy
+] [
+.B \--by-uid
+] [
+.B \--debug
+] [
+.B \--deleted
+] [
+.B \--from
+.I sender
+] [
+.B \--help
+] [
+.B \--host
+.I name
+] [
+.B \--id-only
+] [
+.B \--key
+.I string
+] [
+.B \--larger
+.I number
+] [
+.B \--mailbox
+.I name
+] [
+.B \--new
+] [
+.B \--old
+] [
+.B \--recent
+] [
+.B \--search-key
+.I string
+] [
+.B \--seen
+] [
+.B \--since
+.I dd-Mon-yyyy
+] [
+.B \--smaller
+.I number
+] [
+.B \--subject
+.I string
+] [
+.B \--text
+.I string
+] [
+.B \--to
+.I recipient
+] [
+.B \--unanswered
+] [
+.B \--undeleted
+] [
+.B \--unseen
+] [
+.IB message-ID ...
+]
+.SH DESCRIPTION
+The
+.I mitmailscan
+program scans a folder on an IMAP server for messages. Unless the
+.B \--id-only
+option is given, for each message found,
+.I mitmailscan
+displays a line containing the message ID (sequence number or unique
+identifier), the date sent, the sender, and the subject (the latter two
+fields are truncated to ensure that the output fits on one terminal
+line). The message ID will be followed by \fIU\fR or \fID\fR to denote
+a message which is unseen or deleted, respectively.
+
+When no command line options or arguments are specified,
+.I mitmailscan
+lists all messages in the mailbox. The display can be limited by
+options specifying various search criteria, and by message ID
+arguments. Note that when multiple search-related options are
+specified, the result is the intersection (i.e. logical \fIAND\fR) of
+the matching messages.
+
+For options which require a value argument, the value can be specified
+either as the next argument in the command line, or directly after the
+option name, separated by \fB=\fR.
+
+.I mitmailscan
+understands the following options:
+.TP
+.B \--answered
+display only those messages which have been marked as answered.
+.TP
+.B \--before \fIdd-Mon-yyyy\fR
+display only those messages which were sent earlier than the given date.
+.TP
+.B \--by-uid
+accept and display the message's unique identifier instead of the
+sequence number.
+.TP
+.B \--debug
+turn on debugging.
+.TP
+.B \--deleted
+display only those messages which have been marked as deleted.
+.TP
+.B \--from \fIsender\fR
+display only those messages with \fIsender\fR in the \fBFrom\fR field.
+.TP
+.B \--help
+display usage information and exit.
+.TP
+.B \--host \fIname\fR
+query the given host, instead of the default post office server.
+.TP
+.B \--id-only
+output message IDs only, separated by a space, instead of the standard
+display. This option is useful when you want to specify the message IDs
+as part of another command.
+.TP
+.B \--key \fIstring\fR
+same as \fB--search-key\fR \fIstring\fR.
+.TP
+.B \--larger \fInumber\fR
+display only those messages whose size in bytes is greater than the given
+number.
+.TP
+.B \--mailbox \fIname\fR
+scan the IMAP folder \fIname\fR. If this option is not specified,
+.I mitmailscan
+scans the INBOX folder.
+.TP
+.B \--new
+display only new messages. This option is equivalent to specifying
+\fI--recent --unseen\fR).
+.TP
+.B \--old
+display only those messages which are not marked as recent.
+.TP
+.B \--on \fIdd-Mon-yyyy\fR
+display only those messages sent on the given date.
+.TP
+.B \--recent
+display only those messages which are marked as recent.
+.TP
+.B \--search-key \fIstring\fR
+specifies an explicit IMAP search key (see RFC 2060). This option is
+useful for performing a complex search, i.e. one which cannot be done
+via the other options.
+.TP
+.B \--seen
+display only those messages which are marked as having been seen.
+.TP
+.B \--since \fIdd-Mon-yyyy\fR
+display only those messages sent on or after the given date.
+.TP
+.B \--smaller \fInumber\fR
+display only those messages whose size in bytes is less than the given number.
+.TP
+.B \--subject \fIstring\fR
+display only those messages with \fIstring\fR in the \fBSubject\fR field.
+.TP
+.B \--text \fIstring\fR
+display only those messages with \fIstring\fR in either the header or body.
+.TP
+.B \--to \fIrecipient\fR
+display only those messages with \fIrecipient\fR in the \fBTo\fR field.
+.TP
+.B \--unanswered
+display only those messages which are not marked as having been answered.
+.TP
+.B \--undeleted
+display only those messages which are not marked as deleted.
+.TP
+.B \--unseen
+display only those messages which are not marked as having been seen.
+.SH ARGUMENTS
+.I mitmailscan
+optionally accepts one or more message ID arguments. The ID is
+either the message's sequence number, or, if the
+.I \--by-uid
+option is given, its unique identifier.
+
+The message ID argument can be \fB*\fR, to indicate the last message
+in the mailbox. An argument of the form
+.IB ID1 : ID2
+can be used to specify a range of IDs.
+.SH "SEE ALSO"
+mitmailshow(1), mitmailappend(1), mitmaildel(1),
+imtest(1), RFC\-2060 (Internet Message Access Protocol - Version 4rev1)
Copied: trunk/athena/bin/mitmailutils/man/mitmailshow.1 (from rev 25984, trunk/athena/bin/mitmailutils/mitmailshow.1)
===================================================================
--- trunk/athena/bin/mitmailutils/man/mitmailshow.1 (rev 0)
+++ trunk/athena/bin/mitmailutils/man/mitmailshow.1 2013-05-12 06:24:44 UTC (rev 25985)
@@ -0,0 +1,77 @@
+.\"
+.\" $Id: mitmailshow.1,v 1.1 2004-01-21 23:08:35 rbasch Exp $
+.\"
+.TH MITMAILSHOW 1
+.SH NAME
+mitmailshow \- show messages in an IMAP folder
+.SH SYNOPSIS
+.B mitmailshow
+[
+.B \--by-uid
+] [
+.B \--debug
+] [
+.B \--help
+] [
+.B \--host
+.I name
+] [
+.B \--mailbox
+.I name
+] [
+.B \--no-mark
+] [
+.B \--peek
+]
+.I message-ID
+[ ... ]
+.SH DESCRIPTION
+The
+.I mitmailshow
+program displays each of the specified messages from a folder on an IMAP
+server to the standard output. The output is not filtered; to process
+MIME messages, consider piping the output to the \fImhshow(1)\fR command.
+.SH OPTIONS
+.I mitmailshow
+understands the following options:
+.TP
+.B \--by-uid
+specify that the given message ID arguments are unique identifiers, not
+sequence numbers.
+.TP
+.B \--debug
+turn on debugging.
+.TP
+.B \--help
+display usage information and exit.
+.TP
+.B \--host \fIname\fR
+query the given host, instead of the default post office server.
+.TP
+.B \--mailbox \fIname\fR
+display messages from the IMAP folder \fIname\fR. If this option is
+not specified,
+.I mitmailshow
+displays messages from the INBOX folder.
+.TP
+.B \--no-mark
+do not mark the message(s) as having been seen.
+.TP
+.B \--peek
+same as \fB--no-mark\fR.
+.SH ARGUMENTS
+.I mitmailshow
+requires one or more message ID arguments to be given. The ID is
+either the message's sequence number, or, if the
+.I \--by-uid
+option is given, its unique identifier.
+.I mitmailscan(1)
+can be used to obtain the message ID.
+
+The message ID argument can be \fB*\fR, to indicate the last message
+in the mailbox. An argument of the form
+.IB ID1 : ID2
+can be used to specify a range of IDs.
+.SH "SEE ALSO"
+mitmailscan(1), mitmaildel(1), mhshow(1),
+imtest(1), RFC\-2060 (Internet Message Access Protocol - Version 4rev1)