[Mimedefang] Customer Filter Help (fwd)
Joseph Brennan
brennan at columbia.edu
Mon Mar 31 13:57:01 EST 2003
--On Sunday, March 30, 2003 11:04 -0600 schmaus <schmaus at ties2.net> wrote:
> Here is the code I have, but it does not appear to be
> working:
>
> 1)
> sub filter_bad_filename ($) {
> my($entity) = @_;
> my($bad_exts, $re);
> my($junk,$tdomain);
> my($EXTDB);
> open (HDRS,"./HEADERS");
> while (<HDRS>) {
> if ($_ =~ /^To: /) {
> ($junk,$tdomain) = split(/\@/);
> $tdomain =~ s/\>//g;
> $tdomain =~ tr/A-Z/a-z/;
> }
> }
> close (HDRS);
Maybe what you want to do is cycle through the @Recipients array
instead of reading the To and CC headers? Otherwise, here are
some comments from what I've been working on.
You could take advantage of MIME::Head since we already use the
library anyway, and do something like this in filter_begin, and
then use the values later.
if (open(IN,"<./HEADERS")) {
$head = MIME::Head->read(\*IN);
$from = $head->get('from');
$to = $head->get('to');
$cc = $head->get('cc');
$rec = $head->get('received',0); #most recent one
close(IN);
Note, when using each one, start like this...
if ($to) {
chomp($to);
...since any header might not exist, and you probably don't
want the newline.
Your lines...
while (<HDRS>) {
if ($_ =~ /^To: /) {
($junk,$tdomain) = split(/\@/);
...will not work with multiple addresses, addresses with
comments, addresses without @ signs. Maybe one of those
cases gets you the error.
Joseph Brennan Columbia University in the City of New York
postmaster at columbia.edu Academic Technologies Group
More information about the MIMEDefang
mailing list