#!/usr/bin/perl # # $Id: filter-exch,v 1.4 1997/08/27 22:05:44 vogelke Exp $ # # fix messages that come in via MS Exchange. # the messageid is too long, and since it's forwarded, the reply # address is wrong. $mailrc = "/usr/local/lib/mailrc"; # holds aliases $domain = "c17.com"; # Header while (<>) { last if /^\n$/; s/c=US.a=__.p=GOV.DMS.MILNET.l.// if /^Message-ID:/; if (/^From: /) { $from = $_; } else { push(@hdr, $_); } } # Body: sometimes the "From:" isn't escaped with a leading >. while (<>) { push(@body, $_); chop; if (/^>*From: .*@/) # remote user { s/^>//; $from = $_; last; } elsif (/^>*From: /) # local user { s/^>*From: //; s/\t*//g; tr/,.//d; s/Jr//g; s/Sr//g; s/ [A-Z] //; ($last, $first) = split; open(MAILRC, "$mailrc") || die "$mailrc: $!\n"; while () { chop; if (/$first/ && /$last/) { ($real) = split; $from = "From: \"$first $last\" "; $from .= "<$real\@$domain>"; } } close(MAILRC); last; } } print @hdr; print "$from\n\n"; print @body; print while (<>); exit(0);