Comments, suggestions, questions welcome.
>#!/usr/bin/perl
# Account name assigned to you by TCH.
# i.e., who do you log in to CPanel with?
$accountname = "<accountname>";
# Domain name used for e-mail
$domainname = "<domain.name>";
# Mail account this is active for
# NOT the entire e-mail address. Just
# the section before the '@' sign.
$mailuser = "<mailuser>";
# Location of your default mail target
$target="inbox";
# Read in from standard input and check each
# of our regular expressions. Set targets
# accordingly.
while(<STDIN>) {
if($_ =~ m/^Subject:.*foo/) {
$target="foo";
}
elsif($_ =~ m/^From:.*badguy/) {
$target="badguy";
}
elsif($_ =~ m/^To:.*somelist/) {
$target="somelist";
}
$buffer .= $_;
}
# Location of your main mail folder
$prefix="/home/".$accountname."/mail/".$domainname."/".$mailuser."/";
# Open our target, append our buffer to it, and close it
open(MAILFILE, ">>".$prefix.$target);
print MAILFILE $buffer;
close(MAILFILE);