119 lines
5.1 KiB
PHP
Executable File
119 lines
5.1 KiB
PHP
Executable File
<?php
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
|
|
$dns_records = "";
|
|
$dkim_generated = false;
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['generate'])) {
|
|
$domain = $_POST['domain'] ?? '';
|
|
$selector = $_POST['selector'] ?? 'default';
|
|
$ips_input = $_POST['ips'] ?? '';
|
|
|
|
if ($domain && $ips_input) {
|
|
$dkim_generated = true;
|
|
|
|
// Parser les IPs (une par ligne)
|
|
$ips = array_filter(array_map('trim', explode("\n", $ips_input)));
|
|
|
|
// Générer clé DKIM (2048 bits)
|
|
$private_key = openssl_pkey_new(['private_key_bits' => 2048]);
|
|
openssl_pkey_export($private_key, $private_key_pem);
|
|
$key_details = openssl_pkey_get_details($private_key);
|
|
$public_key = $key_details['key'];
|
|
|
|
// Formater les clés
|
|
$private_key_clean = str_replace(['-----BEGIN PRIVATE KEY-----', '-----END PRIVATE KEY-----', '\n'], '', $private_key_pem);
|
|
$public_key_clean = preg_replace('/-----BEGIN PUBLIC KEY-----(.+?)-----END PUBLIC KEY-----/s', '$1', $public_key);
|
|
$public_key_clean = str_replace(['\n', ' '], '', $public_key_clean);
|
|
|
|
// Générer DNS records
|
|
$dns_records = "=== DNS RECORDS À AJOUTER ===\n\n";
|
|
$dns_records .= "1. DKIM Record:\n";
|
|
$dns_records .= "Nom: {$selector}._domainkey.{$domain}\n";
|
|
$dns_records .= "Type: TXT\n";
|
|
$dns_records .= "Valeur: v=DKIM1; k=rsa; p={$public_key_clean}\n\n";
|
|
|
|
// SPF pour toutes les IPs
|
|
$spf_ips = implode(' ip4:', $ips);
|
|
$dns_records .= "2. SPF Record:\n";
|
|
$dns_records .= "Nom: {$domain}\n";
|
|
$dns_records .= "Type: TXT\n";
|
|
$dns_records .= "Valeur: v=spf1 ip4:{$spf_ips} ~all\n\n";
|
|
|
|
// DMARC
|
|
$dns_records .= "3. DMARC Record:\n";
|
|
$dns_records .= "Nom: _dmarc.{$domain}\n";
|
|
$dns_records .= "Type: TXT\n";
|
|
$dns_records .= "Valeur: v=DMARC1; p=none; rua=mailto:dmarc@{$domain}\n\n";
|
|
|
|
// PTR pour chaque IP
|
|
$dns_records .= "4. PTR Records (à configurer chez le hébergeur):\n";
|
|
foreach ($ips as $ip) {
|
|
$dns_records .= "IP: {$ip} → Pointer vers: mail.{$domain}\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>DKIM Setup Tool</title>
|
|
<style>
|
|
body { font-family: Arial; background: #f5f5f5; padding: 20px; }
|
|
.container { max-width: 900px; margin: 0 auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
|
h1 { color: #333; text-align: center; margin-bottom: 30px; }
|
|
.form-group { margin: 20px 0; }
|
|
label { display: block; font-weight: bold; margin-bottom: 8px; color: #333; }
|
|
input, textarea { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 4px; font-family: Arial; font-size: 14px; box-sizing: border-box; }
|
|
textarea { resize: vertical; min-height: 120px; }
|
|
input:focus, textarea:focus { outline: none; border-color: #2196F3; box-shadow: 0 0 5px rgba(33, 150, 243, 0.3); }
|
|
button { background: #2196F3; color: white; padding: 12px 30px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; font-weight: bold; width: 100%; }
|
|
button:hover { background: #1976D2; }
|
|
.output { background: #f0f0f0; padding: 20px; border-radius: 5px; margin-top: 20px; white-space: pre-wrap; font-family: monospace; font-size: 12px; max-height: 500px; overflow-y: auto; border: 1px solid #ddd; }
|
|
.success { color: green; font-weight: bold; font-size: 16px; margin-bottom: 15px; }
|
|
.help-text { color: #666; font-size: 12px; margin-top: 5px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>🔐 DKIM Setup Tool</h1>
|
|
|
|
<form method="POST">
|
|
<div class="form-group">
|
|
<label>Domaine:</label>
|
|
<input type="text" name="domain" placeholder="ex: vanuatupassport.us" value="<?php echo htmlspecialchars($_POST['domain'] ?? ''); ?>" required>
|
|
<p class="help-text">Le domaine d'envoi (doit matcher le From: de tes emails)</p>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Sélecteur DKIM:</label>
|
|
<input type="text" name="selector" placeholder="ex: default" value="<?php echo htmlspecialchars($_POST['selector'] ?? 'default'); ?>">
|
|
<p class="help-text">Sélecteur DKIM (exemple: default, mail, etc.)</p>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>IPs des serveurs MTA (une par ligne):</label>
|
|
<textarea name="ips" placeholder="110.239.80.20
|
|
110.239.90.190
|
|
110.239.84.59
|
|
110.239.91.217
|
|
182.160.54.210" required><?php echo htmlspecialchars($_POST['ips'] ?? ''); ?></textarea>
|
|
<p class="help-text">Ajoute une IP par ligne. Ces IPs vont dans le SPF.</p>
|
|
</div>
|
|
|
|
<button type="submit" name="generate">🔑 Générer DNS Records</button>
|
|
</form>
|
|
|
|
<?php if ($dkim_generated): ?>
|
|
<div class="output">
|
|
<span class="success">✅ DNS Records générés avec succès !</span>
|
|
|
|
<?php echo htmlspecialchars($dns_records); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</body>
|
|
</html>
|