diff --git a/api/includes/mailer.php b/api/includes/mailer.php index 6840eae..c140bd6 100644 --- a/api/includes/mailer.php +++ b/api/includes/mailer.php @@ -1,33 +1,31 @@ [['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; }