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.

PHP Script generating forwarders programmatically

Discussion in 'cPanel Developers' started by organic, Apr 26, 2009.

  1. organic

    organic Member

    Joined:
    Apr 26, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Hi there,

    I'd like to programmatically add forwarder email addresses to a specific domain. I have an application that needs to give users a custom email address, and I'd like to append that address to the /etc/valiases/domain.com file.

    I have full root/reseller/everything access to the machine, and I'm wondering what's the best way to do this? I'd prefer not to use suPHP.

    What else can I do?

    Thanks, Organic.
     
  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
    You could call the API2 function for adding an email forwarder via our XML API.

    Code:
    <?cp Email::addforward(email=EMAIL,domain=DOMAIN,fwdopt=FWDOPT,failmsgs=FAILMSGS,pipefwd=PIPEFWD,fwdemail=FWDEMAIL ?>
    Where:

    EMAIL = the portion of the email address (to be forwarded) before @. This parameter should never contain the @ symbol.

    DOMAIN = the portion of the email address (to be forwarded) after @. This parameter should never contain the @ symbol

    FWDOPT is fwd if forwarding to an email address, fail if you want to display a failure message, pipe if you want to pipe the email to a shell script in that cPanel account.

    FAILMSGS is used if you selected to display a delivery failure message. This is the failure message that will be sent to the sender of the email.

    PIPEFWD is used if you select to pipe to a shell script. This is a path to the shell script on the cPanel account that owns this email address.

    FWDEMAIL is used if you select to forward to another email address. This is the full email address messages should be forwarded to.

    For documentation on calling this from the XML API, visit: http://twiki.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/CallingAPIFunctions

    If you prefer to use a pre-assembled PHP 5 class, check out Matt's code at: http://forums.cpanel.net/showthread.php?t=111897
     
  3. 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
    ** Moved to the Developer Forum **
     
Loading...

Share This Page