whoisjohngalt Posted March 30, 2004 Share Posted March 30, 2004 Hi all, I was wondering if it is possible to do procmail-type filtering on TCH's servers to filter incoming e-mail into folders? Obviously I'm aware that you can filter on the client, but I check mail through so many different clients, it gets old having to set up each client to filter accordingly. I know that Exim can do this (see this Exim Documentation Snippet) , but it seems as though we are limited to the forwarding functionality that CPanel's interface provides. Any help is appreciated. -M Quote Link to comment Share on other sites More sharing options...
ThumpAZ Posted March 30, 2004 Share Posted March 30, 2004 I don't have an answer for you right this second, but will lok into it a bit. I am going to move this into a more appropriate forum, so it will get better visibility as well. Maybe one of the other folks around here will get you an answer faster than I can. Quote Link to comment Share on other sites More sharing options...
whoisjohngalt Posted April 1, 2004 Author Share Posted April 1, 2004 ^^ BUMP ^^ Does procmail actually exist on the server? /usr/bin/procmail perhaps? Quote Link to comment Share on other sites More sharing options...
TCH-Don Posted April 1, 2004 Share Posted April 1, 2004 Procmail is not installed. And the last I heard, cPanel isnt fully supporting it yet Quote Link to comment Share on other sites More sharing options...
whoisjohngalt Posted April 1, 2004 Author Share Posted April 1, 2004 Procmail is not installed. And the last I heard, cPanel isnt fully supporting it yet From what I've read, people have used CPanel to setup forwards to the procmail binary. For example, use the forward interface in CPanel to forward all mail bound for someuser@mytchhost.com to |/path/to/procmail. If procmail were installed, that should force procmail to scan the user's home directory for .procmailrc and follow and rules that are in there. I understand TCH's desire to not support it, but if it were at least installed, then advanced users could utilize it nontheless as an unsupported and unadvertised feature. There really wouldn't be much to *support*. I really really really really want procmail (or anything similar) to support things like redirecting mail into specific folders for IMAP and such. I have quite a few procmail recipes that I've used for years and now I'm handcuffed on TCH's servers. If procmail will not be *supported* (i.e. installed at all), then is it possible to squeeze more functionality out of the .filter file? I couldn't get it to deliever my mail to anywhere other than my inbox file. Quote Link to comment Share on other sites More sharing options...
whoisjohngalt Posted April 1, 2004 Author Share Posted April 1, 2004 Ok ... here's my hack: I set up a filter in CPanel to filter e-mail destined for my e-mail address to |/home/<accountname>/procmail.pl. procmail.pl is a script I whipped up to try to process incoming e-mail. The following script gives 3 example actions: * Move e-mail with 'foo' in the subject to the folder 'foo' * Move e-mail from any address with 'badguy' in it to the 'badguy' folder * Move e-mail sent TO any address with 'somelist' in it to the 'somelist' folder. Obviously, in this loop, you can place procmail-esque rules and the entire script takes up only slightly more space than a real .procmailrc file. >#!/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); Works like a champ. <----- Me doing the dance of joy. Quote Link to comment Share on other sites More sharing options...
jandafields Posted May 11, 2004 Share Posted May 11, 2004 This is a great script. One question though: What happens if this script trys to open (and write to) MAILFILE while the email server has it open, or vice versa? Looks like it could cause a "conflict"??? Quote Link to comment Share on other sites More sharing options...
Etanisla Posted May 11, 2004 Share Posted May 11, 2004 @jandafields: Thanks for pointing out this thread! Exactly what I was looking for! @whoisjohngalt: Forgive my perl-noobness, but I have a question about your 'hack'... I have three email accounts to my domain. For discussion's sake, let's call them test1, test2, and test3. I am using test3 as my 'catch-all' box. I've copy/pasted your 'hack', and adjusted the necessary entries to match my situation. In cpanel, I made a filter that will send all email specifically to test1@!there.com to /path/to/test1/procmail.pl. Same with test2, and test3. All email sent directly to test1, test2, or test3 work fine. Anything else, that should go to the catch-all, bounces with errors. In the default email address, I set all default email to go to /path/to/test3/procmail.pl. My question is, should I have sent it to test3@!there.com? Or did I misread your script worse than I thought? Quote Link to comment Share on other sites More sharing options...
jandafields Posted May 11, 2004 Share Posted May 11, 2004 In the default email address, I set all default email to go to /path/to/test3/procmail.pl. Make sure you put the pipe symbol before the script like this: |/path/to/test3/procmail.pl It won't work without the pipe! Is your script actually in the test3 folder? You may want that script in your home folder so it isn't directly accessible by www. If you want all unrouted mail to go to test3 without going through the script, put test3@domain.com in the default address box. If you have code in the script to detect unrouted mail and process it, use: |/path/to/your/script.pl Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.