PDA

View Full Version : CMD_API_EMAIL_CATCH_ALL problem



floris
07-19-2006, 03:22 AM
I have a problem setting a user's e-mail Catch All. I use the following code:



define(CATCHALL_FAIL, 0);
define(CATCHALL_BLACKHOLE, 1);
define(CATCHALL_ADDRESS, 2);

function _addcatchall($da_user, $domain, $type, $catch_address="") {
$da = new HTTPSocket;
$da->connect("ssl://" . $GLOBALS["config"]["server_ip"], 2222);
$da->set_login("admin|" . $da_user, $GLOBALS["config"]["da_admin_pass"]);
$da->set_method("POST");

switch($type) {
case CATCHALL_BLACKHOLE :
$da_array = array("domain" => $domain["name"], "catch" => ":blackhole:");
break;

case CATCHALL_ADDRESS :
$da_array = array("domain" => $domain["name"], "catch" => "address", "name" => $catch_address);
break;

default :
$da_array = array("domain" => $domain["name"], "catch" => ":fail:");
break;
}

$da->query("/CMD_API_EMAIL_CATCH_ALL", $da_array);
return $da->fetch_parsed_body();
}


I print_r'ed the $da_array and the contents are valid. I also printed the parameters the function receives, and they are valid too. Other api functions do work. I can set the catch all in directadmin itself.

Any ideas?
Floris

fwpeter
08-18-2006, 01:12 PM
Same problem here. I tried some different DA servers (v1.24.3 and v1.27.4) but none of them seems to work.

Does anyone has a solution or is it a bug?

Maybe we have to notify it to DA staff...

puma75
08-20-2006, 01:58 AM
Im having the same problem.

If you look at the source for the direct admin page, the text box is called value instead of name :

"name" => $catch_address);

"value" => $catch_address);

However this doesnt work for me after the change so I don't know whats wrong.

puma75
08-20-2006, 03:00 AM
The problem seems to be the code we are running is querying the current setting of the catch all, rather than setting it to the value we are supplying.

If you print the results of the operation it tells you the current catch all of the domain if there is one, otherwise says "Fail".

Ive tried adding action => create to the array but that doesn't work.

:mad:

puma75
08-20-2006, 03:22 AM
Hope this helps someone.

I don't know about the API version, but you can do :

$sock->query('/CMD_EMAIL_CATCH_ALL',
array(
'domain' => '{domain}',
'catch' => 'address',
'value' => '{email to forward to}',
'update' => 'Update'
));

This just posts the form like the DA control panel does, the problem is the results you get back is all the html for the page you would see in DA control panel, but you can ignore this.

fwpeter
08-20-2006, 03:27 AM
Ok, nice puma75. I thought I'd tried that before. I will try it once again, hopefully it works. Let u know.

But I think there's a bug in the CMD_API_EMAIL_CATCH_ALL.

fwpeter
08-20-2006, 06:02 AM
That method is working great (I forgot the update->'Update' earlier).

Mitsurugi
08-30-2006, 12:57 PM
Same problem, this is bug and could do with some attention. Are DA staff aware?

fwpeter
08-30-2006, 02:16 PM
Yeah, it would be very nice if it will be fixed. I prefer to use the API call.

cashmere
09-30-2006, 04:07 AM
just add 'update' => 'update' and it will work

fwpeter
09-30-2006, 04:14 AM
True, but not for the API call.

floris
09-30-2006, 04:26 AM
Replace the line


$da_array = array("domain" => $domain["name"], "catch" => "address", "name" => $catch_address);

with


$da_array = array("domain" => $domain["name"], "catch" => "address", "value" => $catch_address, "update" => "Update");

in my first post and everything works fine.

fwpeter
09-30-2006, 04:27 AM
Ok, I'll give it a try!

rwittering
07-09-2008, 07:44 AM
Damn, I just been working over 1 hour finding out why this API call wasn't working...
DirectAdmin, fix the API documentation!!