Create emails accounts using PHP

前端 未结 2 996
半阙折子戏
半阙折子戏 2020-12-30 18:13

I am in the process of trying to create emails using PHP.

This is my code so far it is very basic until I can get a working script. This is the closest I have got bu

相关标签:
2条回答
  • 2020-12-30 18:27

    There is an xml api for cpanel, and some php classes to make the requests. Many people have server configurations that make fopen problematic, but the xmlapi.php file works on many different web hosts.

    include("xmlapi.php");        //XMLAPI cpanel client class
    
    $ip = "127.0.0.1";            // should be server IP address or 127.0.0.1 if local server
    $account = "username";        // cpanel user account name
    $passwd ="password";          // cpanel user password
    $port =2083;                  // cpanel secure authentication port unsecure port# 2082
    $email_domain ="example.com";
    $email_user ="john";
    $email_pass ="johnspassword";
    $email_quota = 0;             // 0 is no quota, or set a number in mb
    
    $xmlapi = new xmlapi($ip);
    $xmlapi->set_port($port);     //set port number.
    $xmlapi->password_auth($account, $passwd);
    $xmlapi->set_debug(0);        //output to error file  set to 1 to see error_log.
    
    $call = array(domain=>$email_domain, email=>$email_user, password=>$email_pass, quota=>$email_quota);
    
    $result = $xmlapi->api2_query($account, "Email", "addpop", $call );
    
    print_r($result);            //show the result of your query
    

    The full list of email functions in the api is available here. https://documentation.cpanel.net/display/SDK/cPanel+API+2+-+Email

    0 讨论(0)
  • 2020-12-30 18:33

    I think this is what you're looking for:

    $socket = fsockopen($cpdomain,2082);
    $cuser = "YourUserName";
    $cpassword = "YourPassword";
    $authstr = base64_encode("".$cpuser.":".$cppass."");
    $in = "GET /frontend/$cpskin/mail/doaddpop.html?email=$euser&$edomain&password=$epass&quota=$equota
    HTTP/1.0\r\nAuthorization: Basic $authstr \r\n";
    fputs($socket,$in);
    fclose( $socket );
    
    0 讨论(0)
提交回复
热议问题