Home

mailtrim : command-line tool to delete mail attachments

Updated December 05, 2006

version 0.4, December 4, 2006
Copyright: © 2006 Alexandre Oberlin


mailtrim: remove various attachments from Berkeley mail archives

Important notes:

  1. Starting from version 1.5, Thunderbird can delete attachements (AKA detach) on a message by message basis. So you will need mailtrim only if you want to delete quickly all attachments of the same type in a mailbox file.
    See Saving and detaching attachments - MozillaZine Knowledge Base
  2. For Thunderbird 1.0, you may check instead:
    AusDilecce Extensions
  3. To save (not detach) Usenet type attachments from command line, try yydecode:
    yydecode

Usage: mailtrim [-iuyh] [ -d outputdir] mailboxfile...
 removes binary attachments in Mozilla/Thunderbird/Netscape mail archives.
 mailtrim takes a Berkeley mailbox file as argument.
 application mime type attachments are always removed. This includes compressed archives as well as executable program files.
 image mime type attachments are removed except if option -i is specified on the command line.
 uuencode attachments are removed except if option -u is specified on the command line.
 yenc attachments are removed except if option -y is specified on the command line.
 The directory where the backup / processed files go may be defined using -d option. Otherwise it defaults to the input file directory.

If any error is detected, no change is made to the input file.
If everything went OK, you'll still be asked if you want to update the mailbox, and the old file will be backed up if you do. You'll have to delete it manually afterwards.

Use at your own risks.


Linux users

mailtrim v0.4 has undergone basic testing on Linux with Netscape 4.76 and Mozilla 1.6.

On Linux with Thunderbird 1.5 and alike, the mailbox files typically reside in

$HOME/.thunderbird/xxxxxxxx.default/Mail/Local Folders 
or
 $HOME/.thunderbird/snz9yu4x.default/Mail/pop.your_isp.com

On Linux with Mozilla 1.6 and alike, the mailbox files typically reside in

$HOME/.mozilla/default/xxxxxxxx.slt/Mail/pop.your_isp.com/

On Linux with Netscape 4.76 and alike, the mailbox files typically reside in

$HOME/nsmail/

The stripped file is saved in the same directory that the original file. You must have write access to this directory.

The executables in the package are not static. They have been built on a modified Fedora 2 system. You'll probably have to compile the source. You might have to modify the makefile.

Quick installation instructions (downloaded archive mailtrim-0.4.tar.gz is in /tmp)

$> cd /tmp
$> tar -xvzf mailtrim-0.4.tar.gz
$> cd mailtrim-0.4
$> make
$> su -c 'make install'			# (enter root password)

Complete package for mailtrim and uudec v0.4, including man page and makefile, plus executable for Linux / Fedora 2


Windows users

The provided command line executable is 32 bits.

mailtrim v0.4 has undergone basic testing on Windows 98 and XP with Netscape 4.72 and Netscape 6.2.

On XP, the mailbox files typically reside in

c:\\Documents and Settings\your_name\Application Data\Mozilla\Profiles\default\xxxxxxxx.slt\Mail\pop.your_isp.com\

On Windows 95/98, the mailbox files typically reside in

c:\\Program Files\Netscape\Users\your_name\Mail\

The trimmed file is saved in the same directory as the original file. XP/NT users, be sure to have write access to this directory (check folder properties).

Compiling should not be necessary, since a win32 command line executable is provided. If you still have to compile from source, the attached makefile mailtrim.mak has been tested with Borland C++ compiler version 5.02. In a DOS box type:

$> make -fmailtrim.mak
You might have to modify the makefile.

Complete package for mailtrim and uudec v0.4, including makefile and executable for Windows