feat: validate email via Emailable, remove auto-download, fix keyboard nav in inputs
All checks were successful
Deploy Production / Deploy to Production (push) Successful in 32s

- Plug Emailable API into checkEmailDeliverability (fail open if no key)
- Show inline red error + shake animation on email field when address is undeliverable
- Remove window.open auto-download after form submission; success now checks result.success
- Disable arrow-key slide navigation when an input or textarea is focused

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-06-08 14:57:03 +02:00
parent 4ea4cd91f5
commit d087012ea8
4 changed files with 117 additions and 13 deletions

View file

@ -49,10 +49,43 @@ function parseContact(array $body): array
return compact('firstName', 'lastName', 'email', 'company', 'role');
}
function checkEmailDeliverability(string $email): bool
function checkEmailDeliverability(string $email, string $apiKey): bool
{
// Plug in an external email validation API here (e.g. Hunter, ZeroBounce, AbstractAPI)
return true;
if ($apiKey === '') {
error_log('[WP] Emailable: no api_key configured, skipping email check');
return true;
}
$url = 'https://api.emailable.com/v1/verify?' . http_build_query([
'email' => $email,
'api_key' => $apiKey,
]);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPGET => true,
CURLOPT_TIMEOUT => 8,
CURLOPT_SSL_VERIFYPEER => true,
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlError = curl_error($ch);
curl_close($ch);
if ($response === false || $httpCode !== 200) {
error_log('[WP] Emailable check failed (HTTP ' . $httpCode . '): ' . $curlError);
return true; // fail open
}
$data = json_decode($response, true);
$state = $data['state'] ?? 'unknown';
error_log('[WP] Emailable response for ' . $email . ': state=' . $state . ' | raw=' . $response);
return $state !== 'undeliverable';
}
function upsertKirbyContact(\Kirby\Cms\Page $page, array $contact): void
@ -179,7 +212,8 @@ return [
$contact = parseContact($body);
if (!checkEmailDeliverability($contact['email'])) {
$emailableApiKey = kirby()->option('emailable_whitepaper', [])['api_key'] ?? '';
if (!checkEmailDeliverability($contact['email'], $emailableApiKey)) {
wpReject(422, 'Undeliverable email');
}