Results 1 to 5 of 5

Thread: Delete forwarder using PHP

  1. #1
    Member
    Join Date
    May 2004
    Posts
    7

    Default Delete forwarder using PHP

    Hi,

    I have a script (obtained on this forum last year) that adds / deletes POP boxes using PHP. I have added a routine to create a forwarder. However, I cannot get one to work that deletes a forwarder. The code I have is:

    Code:
    deletefwd('spam@mydomain.co.uk','forwarded address')
    */
    function deletefwd($email,$forwarded)
    {
    $email=$email . "=" . $forwarded;
    global $cpaneltheme,$cpanelpass,$cpaneluser,$host;
    $request_url="/frontend/$cpaneltheme/mail/dodelfwd.html?email=$email";
    $socket = fsockopen($host,2082,$errno,$errstr);
    if (!$socket) {
       echo "$errstr ($errno)<br />\n";
    }
    $authstr = "$cpaneluser:$cpanelpass";
    $pass = base64_encode($authstr);
    $in = "GET $request_url\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n".
    "Connection: Close\r\n" . 
    "\r\n";
    fputs($socket,$in);
    
    $result_from_action="";
    // for debug
    while (!feof($socket)) {
    $result_from_action.=fgets($socket, 128);
       }
    fclose($socket);
    }
    I know the URL for the deletion needs to be /frontend/$cpaneltheme/mail/dodelfwd.html?email=spam@mydomain.co.uk=forwarded address but can't get it to work. I have tried various ways of getting the $email to concatenate into the required string, but all fail. Any ideas? I think it's the second '= in the query string causing the issue, but can't remember how to avoid this.

    Thanks
    I feel like I am diagonally parked in a parallel universe

  2. #2
    Member
    Join Date
    May 2004
    Posts
    7

    Default hmmmm

    I have now added a line that echoes out the $request_url variable. It shows as /frontend/rvblue/mail/dodelfwd.html?email=spam@mydomain.co.uk=forward@otherdomain.com which, as far as I can see is correct. - the space in the otherdomain.com has been added here. It is not present in the script output.

    If the add forwarder script is working, just by modifying the addpop script, then surely modifying the delpop script, the delforwarder should work? Or am I missing something really obvious?
    Last edited by WoodyUK; 01-09-2005 at 03:17 PM. Reason: update a typo
    I feel like I am diagonally parked in a parallel universe

  3. #3
    Member
    Join Date
    May 2004
    Posts
    7

    Default

    anyone? It's starting to drive me mad now.......
    I feel like I am diagonally parked in a parallel universe

  4. #4
    Member
    Join Date
    Feb 2004
    Posts
    329

    Default

    Does this work:
    PHP Code:
    http://username:password@domain.tld:2082/frontend/theme/mail/dodelfwd.html?email=spam@mydomain.co.uk 
    If so try this:

    PHP Code:
    $delfwd="http://username:password@domain.tld:2082/frontend/theme/mail/dodelfwd.html?email=spam@mydomain.co.uk";
    fopen ($delfwd,"r"); 

  5. #5
    Member
    Join Date
    May 2004
    Posts
    7

    Default

    nope. Afraid that didn't work.

    There must be a way of doing this, since the same script will delete a POP account.
    I feel like I am diagonally parked in a parallel universe

Similar Threads

  1. Invalid eMail Forwarder will not delete
    By biterg in forum cPanel & WHM Discussions
    Replies: 6
    Last Post: 08-04-2011, 07:12 PM
  2. Delete forwarder for non-existent domain
    By paulkoan in forum cPanel & WHM Discussions
    Replies: 4
    Last Post: 12-08-2010, 04:50 PM
  3. Delete Email Forwarder
    By TomHudspeth in forum New User Questions
    Replies: 5
    Last Post: 07-29-2010, 05:26 AM
  4. Delete forwarder using api
    By lazzymonk in forum cPanel & WHM Discussions
    Replies: 6
    Last Post: 03-15-2008, 10:30 AM
  5. Can't delete forwarder?
    By doni49 in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 03-01-2007, 01:10 PM