How do I strip email attachments server side, or send email with attachments to a different address?
January 29, 2004 8:07 PM   Subscribe

How do I strip email attachments server side? Or, alternatively, how do I redirect email containing binary attachments to an alternate email address? I own my own domain and, because I am forced to use Outlook, I don't want attachments touching my inbox. [more inside]

My initial thought was to use procmail, but all the procmail approaches I've seen appear clunky and unreliable, at best. Then again, this is not my forte, so maybe I just don't understand what I'm looking at.

My domain is pretty much full-featured, and I'm willing to switch hosting providers to get the tools I need to do this job right. So any practical technology solution is fair game.

Thanks in advance. I appreciate it.
posted by gd779 to Computers & Internet (10 answers total)
How about having procmail run it through a perl script? Perl has excellent message parsing modules (see, and should be able to do both detection and stripping quite easily. (for redirecting, make the perl script return an exit status based on whether there's a bad attachment or not and then forward based on that).
posted by fvw at 8:34 PM on January 29, 2004

Why are you forced to use Outlook?
posted by Pericles at 2:22 AM on January 30, 2004

what's the problem with procmail (why does it look unreliable)? it's not inherently unreliable (it's the standard mail filtering tool, used everywhere - as i guess you know). is the problem how to select the right messages? if it's just that procmail is complicated, i'd suggest asking a procmail mailing list (or discussion group or wiki or whatever the appropriate support group is).

i don't have to deal with outlook, but i do a simple filter of all incoming messages over a certain size (i also filter based on sender, check against black lists and call spam-assassin). it works reliably.
posted by andrew cooke at 4:07 AM on January 30, 2004

Response by poster: what's the problem with procmail

Procmail is great - for what it does. But it doesn't appear to have been designed for this sort of task, and as a result it doesn't appear to be great at recognizing or dealing with binary attachments.

Then again, maybe I just don't know what I'm talking about. Filtering by size isn't a perfect solution, but it might work in most cases. I hadn't thought of that.

fvw may be on to something with his suggestion. I don't know anything about perl, but I'm looking into it.

Why are you forced to use Outlook?

Because I use NEO. I get far too much email each day to function without it.
posted by gd779 at 8:07 AM on January 30, 2004

NEO claims to "Effortlessly transform Microsoft Outlook into a complete email organizer." Wouldn't it be easier to just use a good e-mail program in the first place, rather than using Outlook plus a third-party add-on to bring it up to par?
posted by kindall at 12:10 PM on January 30, 2004

Response by poster: Wouldn't it be easier to just use a good e-mail program in the first place

Over the years, I've used just about every email program out there, from The Bat! to PicoMail to Netscape to Pine, and nothing lets me handle email as efficiently as NEO. (Well, Pine's more efficient in terms of raw keystroke speed, but NEO makes it easier to track relationships and email history, which is important to me and makes NEO more efficient on the whole).

Using NEO, I cut my time spent on email down from about 2 hours a day to about 30 minutes, plus I'm much more organized, which means I never miss the important emails in the mass of unimportant emails, and I never lose track of the emails I really want to read but don't have time for right now. Plus it's zero-configuration, which I think is an important value in personal information management software.

I'm sorry, I sound like a commercial here, so I'll stop. I just really like the program.
posted by gd779 at 12:51 PM on January 30, 2004

gd779: Predicated on your being root (or able to otherwise su mail) on the mail servers in question, what you're looking for is a combination of the Exim MTA, the < href="">exiscan patches along with the various utilities it uses to cope with attachments, and basic procmail rules.

If your stiffed with another MTA, look into its filtering and tagging possibilities. sendmail offers something called "milters" that seem to be capable of some of this functionality. Postfix probably has something as well, although I'm not familiar enough with it to say what that is. There's pretty much no excuse not to be using Exim in modern times.

If you've only got control of MDA or MUA, Procmail is going to have to do. You'll be writing some shell scripts to string together mime-defang and such to implement your rules. Not pretty, but doable.
posted by majick at 2:22 PM on January 30, 2004

Procmail in conjunction with Anomy Sanitizer
posted by mecran01 at 2:22 PM on January 30, 2004

(Er. Oops. exiscan. Glad I previewed so carefully.)
posted by majick at 2:23 PM on January 30, 2004

Response by poster: Thanks, majick. Following on your suggestion, I think I've found a working solution. After some more testing, I'll come back here and post the details in case anyone with the same question ever finds this post using Google.
posted by gd779 at 12:52 PM on January 31, 2004

« Older 401K Investments   |   Kitty litter changing frequency Newer »
This thread is closed to new comments.