We are running on SpamExperts at this moment, but because we are already using Proxmox VE and SpamExperts is not software we like, we are looking into Proxmox Mail Gateway.
To get the domains in the PMG, we would like to use the API, but the documentation isn`t really straight forward (some examples would be helpful). I made a simple script for adding a domain, but the response is HTTP request failed! HTTP/1.0 401 No ticket.
It would be great if someone can help me out with a working example, so I can work on that to get things running.
To get the domains in the PMG, we would like to use the API, but the documentation isn`t really straight forward (some examples would be helpful). I made a simple script for adding a domain, but the response is HTTP request failed! HTTP/1.0 401 No ticket.
PHP:
$url = 'https://1xx.xx.xxx.251:8006/api2/json/config/domains/';
$cn_match = 'pmg.domain.tld';
$data = array("domain" => "exampledomain.com", "comment" => "Imported");
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-Type: application/json\r\n",
'method' => 'PUT',
'content' => http_build_query($data)
)
, 'ssl' => array(
'verify_peer' => false,
'cafile' => "./cacert.pem",
'ciphers' => 'HIGH:TLSv1.2:TLSv1.1:TLSv1.0:!SSLv3:!SSLv2',
'CN_match' => $cn_match,
'disable_compression' => true,
'verify_peer_name'=>false,
)
);
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
It would be great if someone can help me out with a working example, so I can work on that to get things running.