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.

doaddpop and doadddomain via php

Discussion in 'General Discussion' started by mickie2000, Mar 19, 2004.

  1. mickie2000

    mickie2000 Registered

    Joined:
    Oct 27, 2003
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Updated Sat. Mar 20th
    *------------------------------------------------------
    I've fixed this and run into another... I just needed to swap the order of the auth string and the host and add a connection close before the user data line and it let me in.

    The problem now, is that I get the error "Sorry, you do not have access to the domain <DOMAINNAME>." Anyone have experience with this? I've tried adding the email account directly in Cpanel and it's successful... but my script gets that error for every domain no matter what I try...

    *-----------------------------------------------------------


    I've been messing with this for 2 days and am totally frustrated.

    First... emails. No matter what I try, I'm getting an access denied message from trying to access doaddpop.html via my PHP script. I tried using several versions listed in these forums and none worked, so I re-wrote my own as follows...

    *----- Begin Script

    function addEmailAccount($email, $password, $domain, $quota, $prefix)
    {
    // take in the accounts info... and submit to cpanel
    $error = "";
    $loginInfo = base64_encode($cPanelInfo["user"] . ":" . $cPanelInfo["password"]);
    $accountData = "email=" . $email . "&domain=" . $domain . "." . $extenstion . "&password=" . $password . "&quota=" . $quota;

    if (!$socket = fsockopen($domain, 2082, $errno, $errstr, 30))
    {
    $error .= $errstr . "(" . $errno . ")";
    }
    else
    {
    // build header to send to the webpage
    echo("begin header generation<br>");

    $header = "POST frontend/x/mail/doaddpop.html HTTP/1.1\r\n";
    $header .= "Authorization: Basic " . $loginInfo . "\r\n";
    $header .= "Host: " . $domain . "\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen ($accountData) . "\r\n\r\n";

    if (!fputs($socket, $header . $accountData))
    {
    // output post variables
    $error .="Header Post 112 failed.<br>";
    }
    else
    {
    //Get the reply from the server
    echo($header . "<br>");

    while (!feof($socket))
    {
    echo(fgets($socket, 1024));
    }

    echo("<br>Done.");
    }

    fclose($socket);
    }

    if ($error != "")
    {
    return $error;
    }
    else
    {
    return true;
    }
    }
    *----- end code

    All the echo's are for debugging. The premise is to create an email account for a newly created subdomain after a user signs up...

    second ?....
    Is there a way to configure cpanel or doadddomain.html to add the subdomain directory to a specific place? For example it currently adds the directory in the root of the web directory of the root domain... I'd like to configure this to add it in the /members/X directory where X is the first letter of the username... for organization.
     
    #1 mickie2000, Mar 19, 2004
    Last edited: Mar 20, 2004
  2. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    I can't help with your problem, but would you mind posting your function to add the subdomain?

    I have been trying to figure it out and can't.

    Thanks
    Damion
     
  3. mickie2000

    mickie2000 Registered

    Joined:
    Oct 27, 2003
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Dynamic subdomain and email with CPANEL

    THE SOLUTION -- UNINSTALL CPANEL. Absolutely could not get any help from cpanel or the supposed "experts" so we removed cpanel ad went back to a stripped down Linux server... Everything works flawlessly now.
     
  4. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    The real solution:

    http://forums.cpanel.net/showthread.php?s=&postid=111253#post111253

    After trial and error I got that to successfully add a subdomain.
     

Share This Page