> From:  "Martin Searancke" <[EMAIL PROTECTED]>
> Date:  Wed, 28 Jul 1999 11:23:18 +1000
>
> Im wanting to redirect EMail sent to an alias based on the senders country
> part of the email address. I have used the condredirect before for other
> stuff and thought this would work in this case but there is not the
> environment variable I want.
> e.g. If someone sends an email to [EMAIL PROTECTED] I want a different
> recipient if the senders address ends in .au than if it was .nz.
> 
> There is the $HOST for the address the email was sent to, and $HOST2 etc fo
> r
> the different sections of the receiving address but I can only get the
> complete address of the sender not the country section only.
> 
> Can anyone thin of a way around this?

I've got a script which you can probably adapt easily for these purposes.  

A fine example of a script with more documentation than code.

Chris



#!/usr/local/bin/perl -w

# Quick hack for sorting incoming mail.
#
# By Chris Garrigues 27-Feb-98
#
# Put this in your .qmail file:
#
# |sortonsender myname-sorted
#
# and mail from various sources will be dropped in different inboxes depending
# on where the mail came from.  This mail can be caught at the appropriate 
# level, for example, with the following files:
#
#       .qmail-sorted-default
#       .qmail-sorted-edu-uic-default
#       .qmail-sorted-edu-uic-math-koobera-djb-default
#       .qmail-sorted-edu-uic-math-koobera-djb-qmail
#       .qmail-sorted-edu-uic-math-koobera-djb-ezmlm
#
# Mail from the qmail list would by handled by the 4th file, from the ezmlm 
# list into the 5th file, from Dan into the 3rd file, anyone else at UIC into
# the 2nd file, and the rest of us into the first file.
#

$prefix = $ARGV[0];
$sender = $ENV{SENDER};
$sendto = join('-', $prefix, reverse(split(/[@.]/, $sender))) . "\@$ENV{HOST}";
print STDERR "Forwarding mail from $sender to $sendto\n";
exec('forward', $sendto);
Chris Garrigues                 virCIO
http://www.DeepEddy.Com/~cwg/   http://www.virCIO.Com
+1 512 432 4046                 +1 512 374 0500
                                4314 Avenue C
O-                              Austin, TX  78751-3709
                                

  My email address is an experiment in SPAM elimination.  For an
  explanation of what we're doing, see http://www.DeepEddy.Com/tms.html 

    Nobody ever got fired for buying Microsoft,
      but they could get fired for relying on Microsoft.

PGP signature

Reply via email to