Hi,

I try to find the problems that appear currently and activated the checkbox for enabling the debugging. In SMTP class I find code snippets like "if ($this->do_debug >= 1)" from time to time and with Xdebug I see that the code within this check is reached. I thought "echo" should simply show the text in the browser but it never appears. I do not see any debugging information.

Best,
Tobias

---
I update how the debug works slightly. I redact the password from the logs.
I also remove the smtp_debugging setting. Instead it now uses the log_level is debug.

Issue fork smtp-3104853

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tobiberlin created an issue. See original summary.

bluegeek9’s picture

The SMTP module intercepts PHPMailer's debug output and redirects it to Drupal's logging system instead of echoing to the browser.

1. Lines 260-267: When debugging is enabled, the module sets a custom `Debugoutput` callback that stores debug messages in the session:
260:267:src/Plugin/Mail/SMTPMailSystem.php

      $mailer->Debugoutput = function ($message, $debug_level) {
        $debug_logs = $this->session->get('smtp_debug', []);
        $debug_logs[] = [
          'message' => $message,
          'level' => $debug_level,
        ];
        $this->session->set('smtp_debug', $debug_logs);
      };

2. Lines 961-976: The `debug()` method (called after sending email) retrieves these messages and logs them via Drupal's logger:
961:976:src/Plugin/Mail/SMTPMailSystem.php

  public function debug() {

    $debug_logs = $this->session->get('smtp_debug', []);
    if ($this->smtpConfig->get('smtp_debugging') && $this->currentUser->hasPermission('administer smtp module') && !empty($debug_logs)) {
      $item_list = [
        '#theme' => 'item_list',
        '#items' => [],
      ];
      foreach ($debug_logs as $debug_log) {
        $item_list['#items'][] = $debug_log['message'];
      }
      $debug_logs_message = $this->renderer->render($item_list);
      $this->logger->log('debug', $debug_logs_message);
      $this->session->remove('smtp_debug');
    }
  }

Where to Find the Debug Information

The debug messages are logged to Drupal's database log (watchdog), not echoed to the browser. To view them:

1. Go to `/admin/reports/dblog` (Recent log messages)
2. Filter by the "smtp" channel or severity "Debug"
3. Look for entries with the debug messages

The `do_debug` variable you're seeing is from PHPMailer's internal SMTP class. The module overrides PHPMailer's default `echo` behavior and routes output to Drupal's logging system.

If you need browser output, you'd need to modify the `Debugoutput` callback to echo directly, but that can break AJAX/batch operations, which is why the module uses logging instead.

bluegeek9’s picture

Issue summary: View changes

  • bluegeek9 committed 0b95a029 on 8.x-1.x
    feat: #3104853 Where do I find the debugging info?
    
bluegeek9’s picture

Status: Active » Fixed
//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support makes this project sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:
  • Triage issues and adding more context to existing issues.
  • Flagging SMTP as a favorite on the project page to help others discover it and show your support.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.