Switch email to CyberMail API (orbishosting.com domain)

This commit is contained in:
2026-05-29 13:59:37 +00:00
parent 89f1faa167
commit 844167aad4
+12 -14
View File
@@ -1,33 +1,31 @@
<?php
/**
* Epic Travel Expeditions — SendGrid Mailer
* Epic Travel Expeditions — CyberMail Mailer
*/
function sendgridSend(string $toEmail, string $toName, string $subject, string $htmlBody, string $textBody = ''): bool {
$apiKey = defined('SENDGRID_API_KEY') ? SENDGRID_API_KEY : '';
$apiKey = defined('CYBERMAIL_API_KEY') ? CYBERMAIL_API_KEY : '';
if (!$apiKey || strpos($apiKey, 'YOUR_KEY') !== false) {
error_log('[EpicTravel mailer] SENDGRID_API_KEY not configured');
error_log('[EpicTravel mailer] CYBERMAIL_API_KEY not configured');
return false;
}
$payload = json_encode([
'personalizations' => [['to' => [['email' => $toEmail, 'name' => $toName]]]],
'from' => [
$payload = [
'from' => [
'email' => defined('MAIL_FROM') ? MAIL_FROM : 'noreply@epictravelexpeditions.com',
'name' => defined('MAIL_FROM_NAME') ? MAIL_FROM_NAME : 'Epic Travel Expeditions',
],
'to' => [['email' => $toEmail, 'name' => $toName]],
'subject' => $subject,
'content' => array_values(array_filter([
$textBody ? ['type' => 'text/plain', 'value' => $textBody] : null,
['type' => 'text/html', 'value' => $htmlBody],
])),
]);
'html' => $htmlBody,
];
if ($textBody) $payload['text'] = $textBody;
$ch = curl_init('https://api.sendgrid.com/v3/mail/send');
$ch = curl_init('https://platform.cyberpersons.com/email/v1/send');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
@@ -41,7 +39,7 @@ function sendgridSend(string $toEmail, string $toName, string $subject, string $
curl_close($ch);
if ($httpCode === 202) return true;
error_log('[EpicTravel mailer] SendGrid HTTP ' . $httpCode . ' — ' . $response);
error_log('[EpicTravel mailer] CyberMail HTTP ' . $httpCode . ' — ' . $response);
return false;
}