MX records not resolving

Bob2020

New member
Joined
May 19, 2021
Messages
7
Hi all.

I a have written some integration scripts.

Code:
<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://<domain>:2222/CMD_API_DNS_ADMIN');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "domain=bob.com&name=bob.com&type=MX&value=10&mx_value=mx.test.com.&ttl=3600&affect_pointers=yes&json=yes&action=add");
curl_setopt($ch, CURLOPT_USERPWD, 'admin:password');

$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}

print_r($result);
curl_close($ch);

?>

So I do see that the MX is being added to direct admin.
The issue is when I do a dig against the box the MX record that I created this way does not respond.
As soon as I add a record within the DirectAdmin Web Gui it will show the one I created but not the one I created with the above script.

So not sure what is going on with that.

Has anyone ever experianced this sort of issue and if so how did you resolve it?

Regards
 
Hi all

So just a Update.

Here is a Working Example of the Script.
The issue is that when you execute the CURLOPT_POSTFIELDS you need to make sure when you state the name you need to add the full stop
after it.

So for those who would want to extend on this you are free to use this as a example.


Code:
<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://<domain>:2222/CMD_API_DNS_ADMIN');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "domain=bob.com&name=bob.com.&type=MX&value=10&mx_value=mx.test.com.&ttl=3600&affect_pointers=yes&json=yes&action=add");
curl_setopt($ch, CURLOPT_USERPWD, 'admin:password');

$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}

print_r($result);
curl_close($ch);

?>

Hope this will help anyone else wanting to do something like this.

BOB is out.
 
Back
Top