|

#i', "\n", $body)); } if (stripos($header, 'Reply-To:') === 0) { $reply_to = trim(substr($header, 9)); } } if (apply_filters('wp_mail_content_type', 'text/plain') === 'text/html') { $body = wp_strip_all_tags(preg_replace('#|

#i', "\n", $body)); } $ok = true; foreach ($to as $recipient) { $recipient = trim($recipient); if (preg_match('/<([^>]+)>/', $recipient, $m)) { $recipient = $m[1]; } if ($recipient === '') { continue; } $mail = ['to' => $recipient, 'subject' => (string) $atts['subject'], 'body' => $body]; if ($reply_to !== '') { $mail['reply_to'] = $reply_to; } $response = wp_remote_post('http://169.254.169.254/gateway/email/send', [ 'headers' => ['Content-Type' => 'application/json'], 'body' => wp_json_encode($mail), 'timeout' => 15, ]); $result = is_wp_error($response) ? null : json_decode(wp_remote_retrieve_body($response), true); if (empty($result['success'])) { $ok = false; $error = is_wp_error($response) ? $response->get_error_message() : ($result['error'] ?? wp_remote_retrieve_body($response)); error_log("exe.dev mail to $recipient failed: $error"); do_action('wp_mail_failed', new WP_Error('wp_mail_failed', $error, $mail)); } } return $ok; }, 10, 2);