Anthony DeBoer writes:
> Russell Nelson <[EMAIL PROTECTED]> writes:
> > ... removes MIME
> > the text/html part from a multipart/alternative message.
> >
> > |bin/no-alternative
>
> Is there any chance of this being opensource somewhere? I was searching
> www.qmail.org for a MIME-part-remover just the other day and didn't see
> anything of that ilk. 'Twould be most useful.
#!/usr/bin/perl
while(<>) {
$continuation = 0 if /^\S/;
$continuation = 1 if m!^Content-Type: multipart/alternative;!i;
$boundary = $1 if $continuation && /boundary="(.*?)"/;
last if /^$/;
$headers .= $_ unless $continuation;
}
# dispose of messages which are not multipart/alternative
unless ($boundary) {
exit 0;
}
$boundary =~ s/\W/\\$&/g;
$printing = 0; # we start by discarding the pre-message cuft.
$header = 0; # and we start outside of a header.
open(MAIL, "|forward nelson-alternative") or die;
print MAIL $headers;
while(<>) {
last if /^--$boundary--$/;
if (/^--$boundary$/) {
$header = 1;
$printing = 0;
next; # discard boundary
}
$printing = 0 if $header && m!^Content-Type:!i;
$printing = 1 if $header && m!^Content-Type: text/plain;?!i;
$header = 0 if $header and /^$/;
print MAIL if $printing;
}
close MAIL;
exit 99;
--
-russ nelson <[EMAIL PROTECTED]> http://russnelson.com
Crynwr sells support for free software | PGPok | "Ask not what your country
521 Pleasant Valley Rd. | +1 315 268 1925 voice | can force other people to
Potsdam, NY 13676-3213 | +1 315 268 9201 FAX | do for you..." -Perry M.