mirror of
https://github.com/myronblair/epictravelexpeditions
synced 2026-06-30 17:50:08 -05:00
Switch email to CyberMail API (orbishosting.com domain)
This commit is contained in:
+12
-14
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user