defined('MAIL_FROM') ? MAIL_FROM : 'noreply@epictravelexpeditions.com', 'to' => $toEmail, 'subject' => $subject, 'html' => $htmlBody, ]; if ($textBody) $payload['text'] = $textBody; $ch = curl_init('https://platform.cyberpersons.com/email/v1/send'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($payload), CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . $apiKey, 'Content-Type: application/json', ], CURLOPT_TIMEOUT => 20, CURLOPT_SSL_VERIFYPEER => false, ]); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode === 202) return true; error_log('[EpicTravel mailer] CyberMail HTTP ' . $httpCode . ' — ' . $response); return false; } function sendContactAlert(string $name, string $email, string $message): bool { $adminEmail = defined('ADMIN_EMAIL') ? ADMIN_EMAIL : 'admin@epictravelexpeditions.com'; $subject = "New Contact Form Submission from {$name}"; $html = '

Epic Travel Expeditions

New Contact Form Message

Name ' . htmlspecialchars($name) . '
Email ' . htmlspecialchars($email) . '

' . nl2br(htmlspecialchars($message)) . '

Submitted ' . date('F j, Y \a\t g:i A T') . '

© ' . date('Y') . ' Epic Travel Expeditions

'; return sendgridSend($adminEmail, 'Epic Travel Admin', $subject, $html, "New contact from {$name} ({$email}):\n\n{$message}"); } function sendContactConfirmation(string $toEmail, string $toName): bool { $subject = "We received your message — Epic Travel Expeditions"; $html = '

Epic Travel Expeditions

Thanks for reaching out, ' . htmlspecialchars($toName) . '!

We received your message and our team will get back to you within 1–2 business days.

In the meantime, feel free to browse our destinations and current travel specials:

Explore Destinations

Adventure awaits,
The Epic Travel Team

© ' . date('Y') . ' Epic Travel Expeditions

'; return sendgridSend($toEmail, $toName, $subject, $html, "Hi {$toName},\n\nThanks for contacting Epic Travel Expeditions! We'll get back to you within 1-2 business days.\n\nAdventure awaits,\nThe Epic Travel Team"); }