我正在尝试使用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 :(得分:1)
我找到了解决方案
'<?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";
}
}
?>'