Jump to content

Procmail Clone In Perl


Recommended Posts

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);

Link to comment
Share on other sites

  • 2 years later...

Hello,

 

I found your filter script and was thinking about giving it a try. But I wanted to see if you were still using it and how it has worked out for you over the last 2 years. I don't want to spend time trying to implement it if you have found problems with it over time.

 

Thanks...

 

Brian

Link to comment
Share on other sites

Bruce,

 

Thanks for the reply. I noticed this user hasn't been active since Jan. '06, but I was hoping they may still be lurking around someplace and could give me an update on their experiences with this script. I did review the only other thread I saw this script discussed in, but as you said, that thread was very old also. Has there been any change in TCH's policy regarding more advanced server-side e-mail filtering tools such as ProcMail or Sieve? I don't necessarily even want true support for these other tools, just the ability to use them "at my own risk". I know you can setup basic forwards and filters in cPanel, but unfortunately, those aren't quite doing what I want to do. What I really need to do is filter out Spam to a junk folder, but just for selected e-mail accounts, not all of them. And the filters in cPanel (including the automatic one you can setup in the SpamAssassin configuration screen) apply to all accounts in the domain from what I can tell. Any help in figuring out an efficient way to do that on the server would be appreciated.

 

Thanks...

 

Brian

Link to comment
Share on other sites

I have to say that I'm rather surprised that this type of functionality isn't provided in any supported way on TCH. It would be very useful functionality for users and something that you guys really should consider supporting, even if cPanel doesn't directly support ProcMail or Sieve. Please note, I'm not talking about the products, I'm talking about the functionality. I don't care about a particular product or way or doing something, just that I can accomplish the desired goal (in this case, advanced server-side e-mail filtering). If you could please mention this to the "higher ups" for consideration.

 

Thanks...

 

Brian

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...