PHP - CMD_API_DNS_CONTROL edit records

basdv

New member
Joined
Jan 11, 2020
Messages
2
Hello,

I am trying to remove all existing MX records from a domain and add my own MX-record(s).

I am using the following library to communicate with the API: https://github.com/omines/directadmin
Because this library doesn't include DNS management, I am using the "invokeApiPost" command under the user context of the owner of the domain.

This is my PHP code, with Laravel framework (except for the user context connection, as that part is working for sure):
PHP:
$select = [
    'name' => 'testdomain123.com.', 'value' => '10 mailserver.test.com.'
];
$select = urlencode(http_build_query($select));

$arguments = ['domain' => 'testdomain123.com', 'action' => 'edit', 'mxrecs0' => $select, 'type' => 'MX'];
dd($directadminuser->invokeApiPost('DNS_CONTROL', $arguments));


The "dd" is a dump feature in Laravel. The output I get from the code above is:
POST to DNS_CONTROL failed: You must provide a valid name and value (Cannot Add Record)

Can anyone help me with this? Other suggestions are also welcome, if there for example is an easier way to replace all MX records with one or more new ones.

Regards,
Bas
 
Back
Top