procmail
[Top] [All Lists]

Re: Procmail on Pair Networks - Writing Custom Filters

2010-02-26 11:10:13
Ken,

I've given some info below, inline with your questions ...

On Fri, 2010-02-26 at 15:38 +0000, KW wrote:
Hi,

For one particular purpose, I want to validate incoming [To:]
addresses to confirm that they conform to a certain syntax before
either being delivered to a local mailbox or bounced.
For help with this, you'll need to be more specific ...

Within the Email Management GUI Pair provide something they call a
‘filter’ recipe. Pair’s support tell me that these ‘filters’ can be
written in Python, PHP, Java (in fact, any language available to me on
the server).
The e-mail will be passed to whatever program you designate, and can be
read from the stream /dev/stdin.
Given that you are in this forum, I presume you want to use procmail.

        /usr/bin/procmail -m VAR_1='my_var' ... $HOME/my_code.rc

You would then put your actual code in the file $HOME/my_code.rc, as per
procmail's documentation.

 Unfortunately, Pair provide no further documentation.
That's understandable.  You need to get the documentation from whatever
program (procmail for instance) that you intend to use.

 I have no idea what fields would be passed to my script, the API nor
how I can affect the flow of mail.
Your standard shell variables, plus some specific variables that are set
by procmail, and any that you set on the commandline (such as VAR_1
above).

Searching Procmail’s documentation appears to use the word ‘filter’ in
a more specific manner; referring to files with contents such as this:
:0
* ^Subject:.*\<testing
.testing/
This goes in your source file, which would be $HOME/my_code.rc in the
example above.

The Pair interface uses the following when describing the ‘Filter
recipe’:
In the E-Mail Filter command below, enter the command that should
filter e-mail sent to 
an(_dot_)email(_dot_)address(_at_)mydomain(_dot_)com(_dot_) The command will
be interpreted using the sh shell. If you do not provide an absolute
path to the program, the system will assume the filtering program
lives in your Home directory (/usr/home/#my_username#).
The command to put there is the one I gave you above:

        /usr/bin/procmail -m VAR_1='my_var' ... $HOME/my_code.rc

VAR_1='my_var' is optional, you can put as many variables as you want.
$HOME will already be set correctly.
my_code.rc is the procmail script where you will put your actual code.

I’m not a Linux man and I’m confused. I have no idea how to craft my
script such that it interfaces appropriately to filter (validate) my
incoming mail or control the flow of that mail.
You need to start by getting the basics working, as above.  Any more
advice won't be useful until then.

I’d be very grateful if someone would point in towards some
documentation that might help or give me some pointers. I’m happy to
write my ‘filter’ script in PHP, Python or Java. If I had a preference
at all, it would probably be PHP.
If you want to use a different language, you would not be using
procmail.
You can use any command you want.  Most scripts begin with a "sh-bang"
line that indicates what processor is used to execute the script.
If you would rather use php, then you would call the script directly:

        mycode.php

You can get help with that here ->
http://www.php-cli.com/php-cli-tutorial.shtml


With kind regards,
Ken

Don't hesitate to ask for clarification or for more info.



-- 
JW Simpson <john(_at_)swajime(_dot_)com>
SwaJime's Cove℠

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail