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.

SOLVED cPanel create email account api access issue

Discussion in 'cPanel Developers' started by basheer ahmed, Jun 7, 2017.

  1. basheer ahmed

    basheer ahmed Registered

    Joined:
    Jun 7, 2017
    Messages:
    2
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Pakistan
    cPanel Access Level:
    Root Administrator
    Hi folks, I've been struggling for almost two days but couldn't figure out the exact issue. I've go through documentation and tried several ways to accomplish the task but failed. I need to create an email through Email module using pop function. The email is being created with no errors when I copy and past the below command in shell.

    Code:
    uapi --user=username Email add_pop email=user password=12345luggage quota=0 domain=example.com skip_update_db=1
    
    But the same above command does not work when Try to call in with php code. e.x

    Code:
    $process = new Process($command);
    $process->run();
    dd($process);//Failed to set uid as normal user
    I've also tried the curl way but really that is also returning false and says access denied though I've generated token in my cpanel.

    PHP:
    $curl curl_init();
    curl_setopt($curlCURLOPT_SSL_VERIFYHOST0);
    curl_setopt($curlCURLOPT_SSL_VERIFYPEER0);
    curl_setopt($curlCURLOPT_RETURNTRANSFER1);
            
    $header[0] = "Authorization: whm user:$token";
    curl_setopt($curlCURLOPT_HTTPHEADER$header);
    curl_setopt($curlCURLOPT_URL$url);
    $result curl_exec($curl);
     
  2. basheer ahmed

    basheer ahmed Registered

    Joined:
    Jun 7, 2017
    Messages:
    2
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Pakistan
    cPanel Access Level:
    Root Administrator
    Sorry guys I was passing the wrong token..
     
    Infopro likes this.
Loading...

Share This Page