Contact – Pineapple Express

Contact Us

Questions, bookings, collaborations — send us a note and we’ll get back promptly.

ad>$heading

$heading

$message

← Go back

"; exit; } function sanitize(string $v): string { return trim(preg_replace('/[^\P{C}\t\r\n]+/u', '', $v)); } if ($_SERVER['REQUEST_METHOD'] !== 'POST') { abort_with_message('Invalid request', 'Please submit the contact form.', 405); } // Honeypot if (!empty($_POST['website'] ?? '')) { echo "Thank youOK"; exit; } $name = sanitize($_POST['name'] ?? ''); $email = sanitize($_POST['email'] ?? ''); $phone = sanitize($_POST['phone'] ?? ''); $subject = sanitize($_POST['subject'] ?? ''); $message = trim($_POST['message'] ?? ''); $consent = ($_POST['consent'] ?? '') === 'yes'; if ($name === '' || $email === '' || $subject === '' || $message === '' || !$consent) { abort_with_message('Missing information', 'Please fill all required fields and consent to data storage.', 422); } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { abort_with_message('Invalid email', 'Please enter a valid email address.', 422); } $entry = [ 'ts_iso' => date('c'), 'ip' => $_SERVER['REMOTE_ADDR'] ?? 'unknown', 'name' => $name, 'email' => $email, 'phone' => $phone, 'subject' => $subject, 'message' => $message ]; // Write JSON with lock $ok = false; $retries = 0; do { $fp = @fopen(JSON_PATH, file_exists(JSON_PATH) ? 'c+' : 'c+'); if ($fp === false) break; if (!flock($fp, LOCK_EX)) { fclose($fp); usleep(100000); $retries++; continue; } $contents = stream_get_contents($fp); $data = []; if ($contents !== false && strlen($contents) > 0) { $decoded = json_decode($contents, true); if (is_array($decoded)) { $data = $decoded; } } $data[] = $entry; ftruncate($fp, 0); rewind($fp); $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); $ok = fwrite($fp, $json) !== false; fflush($fp); flock($fp, LOCK_UN); fclose($fp); break; } while ($retries < 3); if (!$ok) { abort_with_message('Storage error', 'Could not save your message. Please try again later.', 500); } // Send SMTP email (PHPMailer) $emailSent = false; try { require_once __DIR__ . '/../vendor/autoload.php'; $mailer = new PHPMailer\PHPMailer\PHPMailer(true); $mailer->isSMTP(); $mailer->Host = SMTP_HOST; $mailer->Port = SMTP_PORT; $mailer->SMTPAuth = true; $mailer->Username = SMTP_USER; $mailer->Password = SMTP_PASS; $mailer->SMTPSecure = SMTP_SECURE; $mailer->setFrom(SMTP_FROM_EMAIL, SMTP_FROM_NAME); $mailer->addAddress(SMTP_TO_EMAIL, SMTP_TO_NAME); $mailer->addReplyTo($email, $name); $mailer->Subject = 'New contact: ' . $subject; $bodyPlain = "New contact submission\n\n" . "Time: {$entry['ts_iso']}\n" . "Name: {$name}\n" . "Email: {$email}\n" . "Phone: {$phone}\n" . "IP: {$entry['ip']}\n" . "Subject: {$subject}\n\n" . "Message:\n{$message}\n"; $bodyHtml = nl2br(htmlentities($bodyPlain, ENT_QUOTES, 'UTF-8')); $mailer->isHTML(true); $mailer->Body = "
{$bodyHtml}
"; $mailer->AltBody = $bodyPlain; $emailSent = $mailer->send(); } catch (Throwable $e) { $emailSent = false; } http_response_code(200); ?> Thank you

Thanks — we’ve got your message.

We’ve stored your enquiry safely. We’ll be in touch shortly.

← Back to contact page