| | |
| | | <?php |
| | | |
| | | namespace JVBase\integrations\services; |
| | | use Exception; |
| | | use JVBase\integrations\Integrations; |
| | | use WP_Error; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | | } |
| | |
| | | |
| | | // Determine content type |
| | | $is_html = $parsed_headers['content-type'] === 'text/html' || |
| | | strpos($message, '<html') !== false || |
| | | strpos($message, '<body') !== false; |
| | | str_contains($message, '<html') || |
| | | str_contains($message, '<body'); |
| | | |
| | | // Build PostMark payload |
| | | $payload = $this->buildEmailPayload( |
| | |
| | | |
| | | return true; |
| | | |
| | | } catch (\Exception $e) { |
| | | } catch (Exception $e) { |
| | | $this->logError('[POSTMARK]', ['method' => 'sendEmail', 'error' => $e->getMessage()]); |
| | | return new WP_Error( |
| | | 'postmark_send_failed', |
| | |
| | | |
| | | switch ($name) { |
| | | case 'content-type': |
| | | if (strpos($value, 'text/html') !== false) { |
| | | if (str_contains($value, 'text/html')) { |
| | | $parsed['content-type'] = 'text/html'; |
| | | } |
| | | break; |
| | |
| | | |
| | | default: |
| | | // Store custom headers |
| | | if (strpos($name, 'x-') === 0) { |
| | | if (str_starts_with($name, 'x-')) { |
| | | $parsed['x-headers'][] = [ |
| | | 'Name' => $parts[0], // Original case |
| | | 'Value' => $value |
| | |
| | | $this->cache->set($cache_key, $stats, 3600); // Cache for 1 hour |
| | | return $stats; |
| | | } |
| | | } catch (\Exception $e) { |
| | | } catch (Exception $e) { |
| | | $this->logError('stats/outbound', ['error' => $e->getMessage()]); |
| | | } |
| | | |
| | |
| | | 'count' => $count, |
| | | 'offset' => $offset |
| | | ]); |
| | | } catch (\Exception $e) { |
| | | } catch (Exception $e) { |
| | | $this->logError('[POSTMARK]', ['method' => 'getBounces', 'error' => $e->getMessage()]); |
| | | return []; |
| | | } |