• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

Mail redirect by size?

One of my email accounts is on an IRIX server.  I use fetchmail to retrieve my mail from this server over a dialup connection.  Is there a way that I can set up the server so that messages over a certain size are automatically redirected to another email address? (Like a .forward file that only applies to certain messages)
0
ZeePrime
Asked:
ZeePrime
  • 3
1 Solution
 
den_tsopaCommented:
i think the only way to do this is to set up .forward file in your home dir to:
"|parse_prog"
and parse_prog will be a script like this:
#!/usr/bin/perl

$letter=<STDIN>;
if (length $letter > 1000) # e.g.
{ open(HANDLE,"| mail ANOTHER_ADDRESS")||die; }
else
{ open(HANDLE,"| LOCAL_FOLDER")||die; }
print HANDLE $letter;
close HANDLE;
0
 
ozoCommented:
$letter=<STDIN>;  #just reads the first line
#you probably wanted something like:
$letter=join'',<STDIN>;
0
 
den_tsopaCommented:
well, of course you're right, ozo, thanx
0
 
den_tsopaCommented:
corrected parse_prog:

#!/usr/bin/perl

$LOCAL_FOLDER="/var/mail/user";
$BIGLETTER_ADDR="bigletter@user.email";
$BIGSIZE=1000;

$letter=join "",<STDIN>;
if (length $letter > $BIGSIZE)
{ open(HANDLE,"| mail $BIGLETTER_ADDR")|| die "cannot pipe: $!\n"; }
else
{ open(HANDLE,">> $LOCAL_FOLDER")||die "cannot open local folder: $!\n"; }
print HANDLE $letter;
close HANDLE;
0
 
ZeePrimeAuthor Commented:
Thanks for the great answer, den_tsopa.  Sorry it took me so long to get you your points - I was on vacation for a month.

Z'
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now