The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Q] Mail Filter: Redirect to Script

Discussion in 'E-mail Discussions' started by ericgorr, Mar 20, 2004.

  1. ericgorr

    ericgorr Registered

    Joined:
    Mar 20, 2004
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    The mail filter docs say one can redirect e-mail to a script:

    but does not provide any further details.

    Has anyone implemented this?
    What does the shell of such a script look like?

    Is there any other documentation that goes into more detail?
     
  2. bamasbest

    bamasbest Well-Known Member

    Joined:
    Jan 10, 2004
    Messages:
    531
    Likes Received:
    0
    Trophy Points:
    16
    Actually, you "pipe" the email to a script.

    Example:

    parsethis@yourdomain.com -> | /home/user/public_html/cgi-bin/emailparser.php

    The script, in the language of your choice (as supported by your platform/install), would do all of the processing from there, depending upon your needs.
     
  3. peterr

    peterr Well-Known Member

    Joined:
    Sep 24, 2003
    Messages:
    75
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    In PHP, the shell of your script would look like this:

    PHP:
    $fd fopen("php://stdin""r");
    $email "";
    while (!
    feof($fd)) {
        
    $email .= fread($fd1024);
    }
    fclose($fd); 
    then the mail is in the var $email, and you can do what you wish with it.

    Hope that helps,

    Peter
     
Loading...

Share This Page