PDA

View Full Version : Get Autoresponders



Allard
03-18-2011, 11:30 AM
Hi,

I have a question. Is there a code, that you can show all autoresponders? I have the below code but how you can show it?


$sock->query('/CMD_API_EMAIL_AUTORESPONDER', array('domain' => 'test.nl'));

zEitEr
03-18-2011, 11:40 AM
Hello,

Use it with HTTPSocket.php (http://www.directadmin.com/forum/showthread.php?threadid=258) in your PHP script. See simple sample (http://www.directadmin.com/sample_api.txt).

Related with this feature http://www.directadmin.com/features.php?id=348

Allard
03-18-2011, 11:43 AM
Thanks, but do you have a good code to show the autoresponders? I tried, but it doesn't work.

zEitEr
03-18-2011, 11:52 AM
What errors did you get? What code did you use? Will you post the code here (without HTTPSocket.php)? I would check it.

zEitEr
03-18-2011, 11:57 AM
To get the list, you should use credentials of the user, who owns the domain, on which the list of autoresponders you wanna get.

Allard
03-18-2011, 11:58 AM
Okey, I have this code but is doesn't work. Can you help me?


public function ShowResponders($Domain)
{
global $sock;
$sock->query('/CMD_API_EMAIL_AUTORESPONDER', array('domain' => $Domain));
$result = $sock->fetch_parsed_body();

switch ($result)
{
case ($result['error'] == 1):
print "There was something wrong with getting all email responders.";
break;
case ($result['error'] == 0):
$responds = print_r($result, true);
foreach($responds as $value)
{
print $value;
}
break;
default:
print "It is not possible to retrieve the responders.";
}

}

Allard
03-18-2011, 12:03 PM
If I put the following code, I get this.


$sock->query('/CMD_API_EMAIL_AUTORESPONDER', array('domain' => $Domain));
$result = $sock->fetch_parsed_body();
print_r($result);

// That give me the result:
Array ( [hoi] => [test] => )

// But how can I show this in a list?

zEitEr
03-18-2011, 12:08 PM
I don't get you. Does any error occur? Or everything is working, but you don't know how to put array indexes into a new array? Or what?

Allard
03-19-2011, 02:17 AM
It already works. Below is the final code.


public function ShowResponders($Domain)
{
global $sock;
$sock->query('/CMD_API_EMAIL_AUTORESPONDER', array('domain' => $Domain));
$result = $sock->fetch_parsed_body();

switch ($result)
{
case ($result['error'] == 1):
print "There was something wrong with getting all email responders.";
break;
case ($result['error'] == 0):
foreach($result as $value => $key){
echo "<responder>$value@$Domain</responder>";
}
break;
default:
print "It is not possible to retrieve the responders.";
}

}

ShowResponders('test.nl');