2016-06-06 4 views
-1

Я пытаюсь проверить, существует ли учетная запись электронной почты в cpanel, используя php и xmlapi .Как проверить, существует ли электронная почта в cpanel

это то, что я сделал.

' $result = $xmlapi->api2_query($account, "Email", "editquota", array('domain' => "mydomain", 'email' => "username", 'quota' => "1024")); 
    if (strpos($result, 'not') == true) { 
      echo 'available'; 
    } 
    else{ 
     echo 'taken'; 
    } 
    $xmlapi->set_output('xml'); 
' 

его всегда берет сообщение «взято».

+0

Не совсем уверен, что этот код пытается сделать с «не» немного, но ваш файл '== true' должен действительно быть'! == false' , –

+0

Функция strpos требует 2 параметра, поэтому я использую 'not' – Thembi

+0

Какова ценность '$ result'? –

ответ

1

IH нашли решение этой

'<?php 
    include("xmlapi.php"); 

    $ip = "10.1.4.1"; 
    $auth_user = 'dave'; 
    $auth_pass = 'secret!'; 
    $cpuser = 'dave'; 

    $xmlapi = new xmlapi($ip); 
    $xmlapi->password_auth($auth_user, $auth_pass); 
    $xmlapi->set_output = 'json'; //using JSON ensures a list reference is returned, even if one result is found 
    $xmlapi->set_port(2083); 

    // for debugging result 
    //$xmlapi->set_debug(1); 

// set to null for a full list, otherwise specify a known domain for  $cpuser 
//$domain_to_hunt_for = null; 
$domain_to_hunt_for = 'extradave.com'; 

if ($domain_to_hunt_for) { 
    $args = array( 
    'regex' => '@' . $domain_to_hunt_for , 
); 
} else { 
     $args = array(); 
} 


$result = $xmlapi->api2_query($cpuser, 'Email', 'listpops', $args); 

if($domain_to_hunt_for){ 
    echo "This is a refined list of emails for the {$domain_to_hunt_for} domain\n"; 

foreach ($result->data as $email_reference) { 
    $email_address = str_replace('@' . $domain_to_hunt_for, '',  $email_reference->email); 
    $email_names[] = $email_address; 
    echo "\t'{$email_address}'\n"; 
} 
}else{ 
echo "This is all the emails addressed related to the {$cpuser} account\n"; 

foreach ($result->data as $email_reference) { 
    echo "\t'{$email_reference->email}'\n"; 
} 
} 
?>' 
Смежные вопросы