CMD_API_EMAIL_CATCH_ALL problem

floris

Verified User
Joined
Oct 23, 2005
Messages
94
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
 
Last edited:
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...
 
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.
 
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:
 
Solution

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.
 
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.
 
Last edited:
That method is working great (I forgot the update->'Update' earlier).
 
Same problem, this is bug and could do with some attention. Are DA staff aware?
 
Yeah, it would be very nice if it will be fixed. I prefer to use the API call.
 
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.
 
Damn, I just been working over 1 hour finding out why this API call wasn't working...
DirectAdmin, fix the API documentation!!
 
Back
Top