Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/lib/dyn_dns/MailinaboxProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

require_once __DIR__ . '/BaseProvider.php';

class MailinaboxProvider extends BaseProvider {
public function updateIp(string $ip): bool {
$email = $this->credentials['mabEmail'] ?? null;
$apiKey = $this->credentials['mabApiKey'] ?? null;
$force = !empty($this->credentials['mabForce']) && $this->credentials['mabForce'] == '1';

if (!$email || !$apiKey) {
$this->logger->error("Missing credentials for Mail‑in‑a‑Box DDNS: {$this->domain}");
return false;
}

$url = "https://{$this->credentials['mabHost']}/admin/dns/update";
$postFields = http_build_query([
'force' => $force ? 1 : 0,
]);

$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => "$email:$apiKey",
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postFields,
CURLOPT_HTTPHEADER => ["Content-Type: application/x-www-form-urlencoded"],
]);

$resp = curl_exec($ch);
if ($resp === false) {
$this->logger->error("Mail‑in‑a‑Box /dns/update request failed: {$this->domain}");
return false;
}
curl_close($ch);

if (strpos($resp, 'updated DNS:') !== false) {
$this->logger->info("Mail‑in‑a‑Box DDNS updated for {$this->domain}: $resp");
return true;
} else {
$this->logger->error("Mail‑in‑a‑Box DDNS update failed for {$this->domain}: $resp");
return false;
}
}
}
2 changes: 2 additions & 0 deletions src/lib/dyn_dns_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require_once __DIR__ . '/dyn_dns/StratoProvider.php';
require_once __DIR__ . '/dyn_dns/NamecheapProvider.php';
require_once __DIR__ . '/dyn_dns/CloudflareProvider.php';
require_once __DIR__ . '/dyn_dns/MailinaboxProvider.php';
require_once __DIR__ . '/dyn_dns/HetznerProvider.php';

$domainManager = new PersistentEntityManager(Domain::class, $logger, DB, 'domains');
Expand Down Expand Up @@ -34,6 +35,7 @@
'strato' => StratoProvider::class,
'namecheap' => NamecheapProvider::class,
'cloudflare' => CloudflareProvider::class,
'mailinabox' => MailinaboxProvider::class,
'hetzner' => HetznerProvider::class,
default => null,
};
Expand Down
7 changes: 7 additions & 0 deletions src/public/domains.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
<option value="strato">Strato</option>
<option value="namecheap">Namecheap</option>
<option value="cloudflare">Cloudflare</option>
<option value="mailinabox">Mailinabox</option>
<option value="hetzner">Hetzner</option>
</select>

Expand Down Expand Up @@ -350,6 +351,12 @@
{ label: 'API Token', id: 'cfApiToken', type: 'text' },
{ label: 'Zone ID', id: 'cfZoneId', type: 'text' }
],
mailinabox: [
{ label: 'Host (box.example.com)', id: 'mabHost', type: 'text' },
{ label: 'Email (admin user)', id: 'mabEmail', type: 'text' },
{ label: 'API Key', id: 'mabApiKey', type: 'password' },
{ label: 'Force Update (0 or 1)', id: 'mabForce', type: 'text' }
],
hetzner: [
{ label: 'API Token', id: 'hetznerApiToken', type: 'text' },
{ label: 'Zone ID', id: 'hetznerZoneId', type: 'text' }
Expand Down
Loading