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.

A question about the outbox, so to say it...

Discussion in 'E-mail Discussions' started by guldvog, Oct 23, 2008.

  1. guldvog

    guldvog Member

    Joined:
    Mar 10, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Ozamiz City, Philippines
    cPanel Access Level:
    Root Administrator
    Hi there :)

    Yesterday I aquired a domain name, domain.com - and on that domain name (desktop in English) I have a little special question:

    Is it possible to say send an Email to an account named outbox@domain.com, and then to let that account forward (resend) the Email to an Address specified in the Email header (or even in the Email body) automatically - without any kind of human intervention?

    Thank you very much for any good Ideas! :)

    Regards
    Jan Guldvog
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    What you could do is set up a forwarder for outbox@domain.com - but instead of forwarding it to another (static) email address, you can pipe this into a shell script. This can be a PHP shell script, which is just like a regular PHP script but with a #! line at the top indicating the location of the PHP interpreter. This script can handle the header processing and resending of the message for you.
     
  3. guldvog

    guldvog Member

    Joined:
    Mar 10, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Ozamiz City, Philippines
    cPanel Access Level:
    Root Administrator
    Interesting :)

    I have never tried this - do you have a working example to show me?

    Regards
    Jan
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Here's generally what your PHP code would look like (below). Of course, there would be much more here to handle the actual processing of the email message and calling mail() to send the new email message accordingly.

    Note the first line of the file, that's what makes this a PHP shell script. Like any shell script, it will need executable permissions as well.

    PHP:
    #!/usr/bin/php -q
    <?php

    $emailMessage 
    file_get_contents("php://stdin");

    # More PHP code can go here to handle the mail message

    # Refer to http://www.php.net/function.mail to learn how to send email via PHP

    ?>
     
Loading...

Share This Page