![]() | Welcome to Islandnet.com Locally owned and operated since 1993 |
| Create an Account • Pricing & Features • Domain Registration • Customer Sites • Help & Info | |
Tuesday May 13 2008 | |
PEP DocumentationReturn to the help indexPages: Quickstart • Actions • Headers • Tests • Commands • Attachment Handling • Reply Files • Mailing Lists • Child Accounts • DNS Blocklists • SpamAssassin • Challenges • M-Script • Glossary • Spam FAQ • SMTP Tutorial • PEP Quick Setup • PEP Wizard • PEP Editor
Launching M-Script Programs (Advanced)This page provides more detailed information about using PEP's "exec" feature. It is assumed that you know the basics about creating a mailrule file and constructing rules. It is also expected that you're familiar with creating and using M-Script programs.This page does not attempt to teach you how to write M-Script programs. For that, please visit http://www.islandnet.com/mscript/.
What is an "M-Script Program"?M-Script is a programming language that was originally designed for writing CGI applications for web pages, but now it can also be used to write programs that run from within PEP. M-Script is an easy programming language to learn: it's similar to BASIC or dBase programming.
Why?There are many examples of why you might want to launch a program upon reception of an e-mail message. You could create a program that generates a web archive of certain mailing list messages for example. Or you might use this to process e-mail based product orders.
How does it work?To launch an M-Script program from within PEP you must do two things. First you need to write your M-Script program, then you need to add a rule that causes it to run.The rule is the easy part. Here's a sample PEP rule that launches (executes) an M-Script program called "archiver.ms2":
The program itself must have a ".ms2" extension and must be located in your "ms2" directory, as per the M-Script documentation. In the example above, we launch the M-Script program without passing the message itself to the program. The program will run, but it has no way of accessing the headers or the body of the message. Depending on what the program does, this may or may not be what you want. If you want your program to have access to the message, you need to specify an additional parameter in your rule. This is the name of a file to which a copy of the message will be saved prior to launching your program:
If your program exits with a value of zero, PEP halts without delivering your message. This makes it effectively the same a s DELETE rule. If the program exits with a non-zero value, PEP continues processing the rest of your mailrule file. NOTE:
Environment VariablesPrior to launching your M-Script program, PEP defines the following environment variables which you can read from within your program with the getenv() function:
An ExampleFor this example we simply want to count messages from our Visual Basic mailing list that happend to include the string "[VBS]" in every subject header. The count will be stored in the file "vbs.count" in our root directory:We start with a rule like the following:
Since we're simply counting occurances of such messages, we don't need to pass the actual messages to the program. Next we create the file "counter.ms2" in our "ms2" directory. It would look something like this:
And that's it. Every time we get a message with "[VBS]" in the subject, the program runs and adds 1 to the value in the "vbs.count" file. Note the last line which returns a value of one to PEP. This will cause PEP to continue testing the message against your mailrule file. Unless a subsequent rule deletes it, it will be delivered to your mailbox.
|
| Home • About Us • Contact Us • Terms of Use • Privacy Policy • Help Documents |
| Page generation time: 0.11 seconds |