/** * @wp-hook schedule_event * * @param stdClass $event * * @return stdClass */ public function record_schedule_event(stdClass $event) { if ($this->event_name !== $event->hook) { return $event; } $run_at = new DateTime('now', new DateTimeZone('UTC')); $run_at->setTimestamp($event->timestamp); $this->logger->info("Schedule next mail transport", ['time_utc' => $run_at->format('Y-m-d H:i:s'), 'object_id' => $event->args[0], 'object_type' => $event->args[1], 'recipients' => $this->recipient_filter->filter_recipients($event->args[2])]); return $event; }
/** * @wp-hook wp_mail_failed * * @param WP_Error $error */ public function record_mail_error(WP_Error $error) { $error_data = $error->get_error_data(); $error_data['to'] = is_array($error_data['to']) ? $this->recipient_filter->filter_recipients($error_data['to']) : $this->recipient_filter->filter_recipients(explode(',', $error_data['to'])); foreach (['cc', 'bcc'] as $key) { if (!isset($error_data['headers'][$key])) { continue; } if (is_array($error_data['headers'][$key])) { $error_data['headers'][$key] = $this->recipient_filter->filter_recipients($error_data['headers'][$key]); continue; } $error_data['headers'][$key] = $this->recipient_filter->filter_recipients(explode(',', $error_data['headers'][$key])); } $this->logger->notice("WP mail failed: {$error->get_error_message()}", ["error_data" => $error_data]); }