[NBLUG/talk] Mail Removal

Ron Wickersham rjw at alembic.com
Wed Apr 7 10:56:58 PDT 2004


On Wed, 7 Apr 2004, Steve Johnson wrote:

> We have an issue where an e-mail was sent out to about 1300 users, and I
> need to remove them from their mail spools.  Not sure how I am going to do
> this, does anyone by chance have a script or know of one that will
> do this, maybe one where I can give it the subject and the from line and
> it will go through and remove all e-mail under that criteria out
> of every box in the mail spool? (/var/mail)  This is on a linux box.
>
>
> Any help would be greatly appreciated.  Thanks.
>
> -Steve

<background>
there is an ethic of system administrators that goes against digging into
mail spools of users.  while root has the technical ability to accomplish
what you ask, privacy concerns without a written policy otherwise make it
a legal mine trap to do what you ask.   and there may be an impossibility
to get rid of all the copies if some mailboxes are on other machines that
are not in your control.  for a discussion of this topic see page 854
"Boss's mistake #2" in the Green book "Linux Administration Handbook" by
Evi Nemeth, et. al. (or if you have the previous red or purple editions
which were titled "Unix System Administration Handbook").  there is some
expectation that sending an e-mail is something like dropping a letter in
a post office box...once it's in the box you can't ask a postal employee
or even the Postmaster to get it back for you.
</background>

but on to how to do what you want.  in the regular Unix mail format, all
the messages in each person's inbox is concatenated into one file, which
is stored as the user's name.

there is a blank line separating each message and following the blank line
is the envelope line that starts with "From" with a space following the
word From, so it's actually "From ".   (note that this is distinct from the
message header from line which has a colon and has the form "From:").
so you can use a regular expression to look for the "From " identifier
and then look a few lines below for the "Subject:" line that has the
offending mail's subject line.   then delete from the original "From "
line to the next occurrence of the "From " identifier.  when you're
finished there should still be a blank line between the preceeding message
and the "From " line of the now next message.

-ron

--
/~\  The ASCII Ribbon Campaign
\ /    No HTML/RTF in email
 X     No Word docs in email
/ \  Respect for open standards





More information about the talk mailing list