<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FreeSMTP — Email Relay API</title>
<style>
  body { font-family: -apple-system, system-ui, sans-serif; max-width: 720px; margin: 40px auto; padding: 0 20px; line-height: 1.6; color: #333; }
  h1 { color: #1a73e8; border-bottom: 2px solid #eee; padding-bottom: 10px; }
  pre { background: #f4f4f4; padding: 12px; border-radius: 6px; overflow-x: auto; font-size: 14px; }
  code { background: #f0f0f0; padding: 2px 5px; border-radius: 3px; }
  .endpoint { background: #e8f4fd; padding: 8px 15px; border-radius: 6px; font-weight: bold; display: inline-block; }
  table { width: 100%; border-collapse: collapse; margin: 15px 0; }
  th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #ddd; }
  th { background: #f8f9fa; }
  .status { color: #0d652d; background: #ceead6; padding: 2px 8px; border-radius: 3px; font-size: 13px; }
  .warning { background: #fef7e0; border-left: 4px solid #f9ab00; padding: 12px; border-radius: 4px; margin: 20px 0; }
</style>
</head>
<body>
<h1>📧 FreeSMTP</h1>
<p>Self-hosted HTTP-to-SMTP email relay. Send emails via your own SMTP server.</p>

<div class="warning">
  <strong>⚠️ IMPORTANT voor deliverability (geen spam):</strong><br>
  1. Stel <strong>SPF</strong> TXT record in voor mail.baksteenservice.be<br>
  2. Zet <strong>DKIM</strong> signing aan (genereer keys en zet DNS record)<br>
  3. Zet <strong>DMARC</strong> TXT record (<code>v=DMARC1; p=none;</code>)<br>
  4. Gebruik een SMTP-server met goede reputatie
</div>

<h2>API Endpoint</h2>
<p class="endpoint">POST https://test.baksteenservice.be/freesmtp/</p>

<h3>Headers</h3>
<table>
  <tr><th>Header</th><th>Waarde</th></tr>
  <tr><td><code>Content-Type</code></td><td><code>application/json</code></td></tr>
  <tr><td><code>X-API-Key</code></td><td>Je API key (uit config.php)</td></tr>
</table>

<h3>Request Body</h3>
<pre>{
  "to":      "recipient@example.com",
  "subject": "Test Email",
  "body":    "Plain text content",
  "html":    "&lt;h1&gt;HTML versie&lt;/h1&gt;",     // optioneel
  "from_email": "noreply@mail.baksteenservice.be",  // optioneel
  "from_name":  "FreeSMTP",                         // optioneel
  "cc":         "cc@example.com",                   // optioneel
  "bcc":        "bcc@example.com",                  // optioneel
  "reply_to":   "reply@example.com"                 // optioneel
}</pre>

<h3>Per-request SMTP override</h3>
<p>Voeg deze velden toe om een andere SMTP-server te gebruiken:</p>
<pre>{
  ...email velden...,
  "smtp_host":       "smtp.andere-provider.com",
  "smtp_port":       465,
  "smtp_encryption": "ssl",
  "smtp_username":   "user@provider.com",
  "smtp_password":   "password"
}</pre>

<h3>cURL voorbeeld</h3>
<pre>curl -X POST https://test.baksteenservice.be/freesmtp/ \
  -H "Content-Type: application/json" \
  -H "X-API-Key: jouw-api-key" \
  -d '{
    "to": "test@example.com",
    "subject": "Hallo vanuit FreeSMTP",
    "body": "Dit is een testmail."
  }'</pre>

<h3>Response</h3>
<pre>{
  "status": "sent",
  "message_id": "&lt;abc123@mail.baksteenservice.be&gt;"
}</pre>

<h2>Configuratie</h2>
<p>Bewerk <code>/var/www/test.baksteenservice.be/freesmtp/config.php</code> om:</p>
<ul>
  <li>SMTP credentials in te stellen</li>
  <li>DKIM signing aan te zetten (genereer keys met <code>openssl genrsa -out /path/to/dkim-private.pem 2048</code>)</li>
  <li>Rate limieten aan te passen</li>
  <li>API key te wijzigen</li>
</ul>
<p>✅ <span class="status">ACTIEF</span> — Server time: 2026-09-01 11:57:53</p>
</body>
</html>
