<?php
$page_title = 'Setup — getting a Transactional API key';
require 'header.php';
?>

<p>
    Mailchimp Transactional is a <strong>paid add-on</strong> to a Mailchimp
    account — it's separate billing from the Marketing side. Here's the full
    path from zero to a working API key.
</p>

<h2>Step 1 — Have (or create) a Mailchimp account</h2>
<p>
    Sign up at <a href="https://login.mailchimp.com/signup/" target="_blank" rel="noopener">mailchimp.com/signup</a>
    if you don't already have one. The free tier is fine for this — you only need a paid Marketing plan if you
    want to use subaccounts and some advanced features on the Transactional side.
</p>

<h2>Step 2 — Enable Transactional Email on the account</h2>
<p>Once logged into Mailchimp:</p>
<ol class="big-steps">
    <li><strong>Click your profile icon</strong> (top right) → <em>Account &amp; billing</em>.</li>
    <li><strong>Open the "Transactional Email" tab.</strong></li>
    <li><strong>Choose a plan and buy at least one block of sends.</strong>
        Transactional is priced in "blocks" — 25,000 emails is the smallest block
        (around $20 at the time of writing, but check the current pricing on the
        page). You have to buy the first block before the dashboard unlocks.</li>
    <li><strong>Click "Launch App"</strong>. This opens the Mandrill dashboard
        at <code>mandrillapp.com</code> — the Transactional side of Mailchimp
        still uses the old Mandrill URLs.</li>
</ol>

<div class="callout info">
    <strong>Why it's paid-only:</strong> Transactional email has strict anti-abuse
    requirements (verified domains, reputation monitoring, dedicated IP warmup),
    so there isn't a free tier the way there is for newsletters.
</div>

<h2>Step 3 — Generate an API key</h2>
<ol class="big-steps">
    <li>In the Mandrill dashboard, go to <strong>Settings</strong> (gear icon, top right).</li>
    <li>Find the <strong>SMTP &amp; API Info</strong> section.</li>
    <li>Click <strong>New API Key</strong>. Optionally give it a description like "elegantwork demo".</li>
    <li><strong>Copy the key</strong> — it's a long random string. This is the only time it'll be shown in full; treat it like a password.</li>
</ol>

<h2>Step 4 — Paste it into <code>config.php</code></h2>
<p>Open <code>config.php</code> in this demo and replace the placeholder:</p>
<pre><code>define('MANDRILL_API_KEY', 'md-xxxxxxxxxxxxxxxxxxxxxx');</code></pre>

<p>
    Then reload <a href="01-ping.php">Step 1: Ping</a>. If it returns
    <code>{"PING": "PONG!"}</code> you're connected.
</p>

<h2>Step 5 — Verify a sending domain (required before you can send email)</h2>
<p>
    You can <em>manage the allowlist</em> without this, but the moment you want
    to actually send mail (Step 5 of the demo), the <code>from_email</code> must
    be on a domain you've verified. In the Mandrill dashboard:
</p>
<ol class="big-steps">
    <li><strong>Settings → Sending Domains.</strong></li>
    <li>Add your domain (e.g. <code>elegantwork.co.za</code>).</li>
    <li>Publish the three DNS records Mandrill gives you:
        <ul>
            <li><strong>SPF</strong> — a TXT record so receiving mailservers know Mandrill is allowed to send as you.</li>
            <li><strong>DKIM</strong> — a TXT record with a public key, so receivers can verify mail was signed by you.</li>
            <li><strong>Verification</strong> — usually Mandrill emails a link to <code>admin@yourdomain</code> or similar; click it.</li>
        </ul>
    </li>
    <li>Hit <strong>Test DNS Settings</strong> in Mandrill until all three go green.</li>
</ol>

<p>Then update <code>config.php</code>:</p>
<pre><code>define('DEFAULT_FROM_EMAIL', 'noreply@elegantwork.co.za');
define('DEFAULT_FROM_NAME',  'Elegant Work');</code></pre>

<h2>Security notes</h2>
<div class="callout warn">
    <strong>Never commit <code>config.php</code> to a public repo.</strong>
    For a production setup, move the key into an environment variable or a
    file outside the web root and <code>require</code> it from there. This
    demo keeps it inline for simplicity, but add <code>config.php</code> to
    your <code>.gitignore</code> if you're versioning this folder.
</div>

<p><a href="01-ping.php">→ Once you've pasted the key, continue to Step 1: Ping</a></p>

<?php require 'footer.php'; ?>
