diff --git a/includes/steps/115-email.php b/includes/steps/115-email.php index ea57a8a..bf8d6c1 100644 --- a/includes/steps/115-email.php +++ b/includes/steps/115-email.php @@ -150,13 +150,26 @@ return new class extends WPH_Step { // mangle the formatting. $session = WPH_Session::current(); if ($session && $debug_requested) { + $trace = array_slice($trace, 0, 200); // cap to avoid bloating the option $data = $session->data(); $data['email_debug'] = [ 'captured_at' => time(), 'transport' => $transport, - 'trace' => array_slice($trace, 0, 200), // cap to avoid bloating the option + 'trace' => $trace, ]; update_option(WPH_OPT_SESSION, $data, false); + + // Append the trace to the step's notes so the technician can edit + // it and so it lands in the downloadable report (notes are + // already serialised verbatim). + $current_state = $session->step_state($this->id()); + $current_notes = (string) $current_state['notes']; + $stamp = date('Y-m-d H:i'); + $block = "\n\n--- SMTP debug trace (" . $stamp . ", transport: " . $transport . ", to: " . $to . ") ---\n"; + $block .= $trace ? implode("\n", $trace) : '(no trace lines captured — transport does not emit SMTP traffic)'; + $block .= "\n--- end trace ---"; + // Keep whatever status the technician had previously chosen. + $session->update_step($this->id(), (string) $current_state['status'], trim($current_notes . $block)); } $time = date('Y-m-d H:i');