I continue to have problems sending emails with the SMTP Authentication Support module in my Drupal 10.2.4 site with php 8.2.17 that's hosted on a GoDaddy.com Virtual Private Server.

The system log shows that e-mails are being sent,

Mail sent to ulandreman@gmail.com with subject Drupal SMTP test e-mail:

To: ulandreman@gmail.com
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8Bit
X-Mailer: Drupal
Return-Path: <info@landreman.com>
Sender: info@landreman.com
From: Landreman family <info@landreman.com>
Subject: Drupal SMTP test e-mail

If you receive this message it means your site is capable of using SMTP to
send e-mail.

but the intended recipients never receive them.

Working with the tech staff at GoDaddy, we've shown that the email system works on the server.  However, no messages sent from the Drupal site ever appear in the relay information on the server.

The problem seems to be somewhere in the interface between Drupal and the server.

One clue that things are amiss is that when I'm on Configuration page of the SMTP Authentication Support and I send a test e-mail with the Enable debugging box checked, I do NOT see the list of messages flash on the screen.  I've seen this with other Drupal sites, so I know what should be appearing.

I don't know enough of the inner-workings of Drupal's mail infrastructure to know what might be causing the trouble. 

What file (X.php?) does the actual display of the Enable debugging information?

Is the information that "should" be displaying stored in some log file somewhere?  If so, which one?

Where should I put some display statements to track how far the system gets after logging the "Mail sent to ..." message before it stops?

Thanks for any help.

Comments

katorymnd’s picture

  1. Checking PHP Configuration:

    • Ensure that your PHP configuration (php.ini) allows for error logging (log_errors = On) and specifies an error log file (error_log = /path/to/php-error.log).
    • Verify that PHP's mail() function is not disabled (disable_functions directive in php.ini) as some modules might fall back to using it under certain configurations.
  2. Drupal & Server Mail Configuration:

    • Ensure your Drupal site's email settings in the SMTP Authentication Support module are correctly configured, including SMTP server, port, encryption method, and authentication credentials.
    • Check with GoDaddy support if there are any restrictions or special configurations needed for sending SMTP emails from your VPS.
  3. What File Handles Debugging Display?: The SMTP module's debugging output is generated by the module itself. Look into the SMTP module's directory, particularly for files like smtp.mail.inc or similarly named ones that handle mail sending functionality. Debugging output is typically handled through these scripts, especially in functions that deal with sending or testing emails.

  4. Where to Add Custom Debug Statements:

    • To trace the mail-sending process further, you can start by adding custom PHP error_log statements in the SMTP module, particularly around the sections where emails are being sent or where debugging information is generated.
    • A good starting point is right before and after the call to the mail sending function in the SMTP module. This way, you can confirm if the module attempts to send the email and whether it encounters any errors immediately after.
ulandreman’s picture

Thanks for the note and your suggestions.

I'll check them out to see if they help solve this mystery.

ulandreman’s picture

So, I see in the module vendor/phpmailer/phpmailer/src/SMTP.php, the program is putting out messages, such as
     $this->edebug(
            "Connection: opening to $host:$port, timeout=$timeout, options=" .
            (count($options) > 0 ? var_export($options, true) : 'array()'),
            self::DEBUG_CONNECTION
        );

that appear on the list of messages from the STMP session that flashes quickly on the screen when you are in the Configuration/SMTP Authentication Support page and you click on Enable Debugging and send a test email - at least it does that when things work.

Where is the log file that those messages get stored?
I don't see them in the admin/reports/recent log messages log.
I don't see them if I go to the Drupal database and look at the watchdog table.

I assume that they're written out somewhere.  I just haven't been able to find that file to troubleshoot effectively.

Can you point me in the right direction?

ulandreman’s picture

I'm still unclear what was causing the mail messages not to be delivered, but I uninstalled the helper module and then suddenly things started working.

The phrase our team used decades ago was "It's another mystery of data processing".

Regardless, the mail is going through, so all is good with the world.

jeff.a’s picture

Exact same question. Did you figure this out or where the verbose gets printed/stored? Flashing on the screen for 1 second doesn't seem like the intended functionality. I'm on Pantheon.

ulandreman’s picture

No.  I never did figure out where all the messages go.
I just adjusted and re-adjusted the parameters until it started working.

Sorry.

mykola dolynskyi’s picture

It does not go anywhere because debug print function is not implemented by SMTP module authors 

web/modules/contrib/smtp/src/Plugin/Mail/SMTPMailSystem.php

    // Turn on debugging, if requested.

    if ($this->smtpConfig->get('smtp_debugging')

      && $this->currentUser->hasPermission('administer smtp module')) {

      $mailer->Debugoutput = function($str, $level) {

// drupal set message $str

      };

      $mailer->SMTPDebug = TRUE;

    }

mikcat’s picture

Looks like all debug info is before the doctype html tag...

....
2025-03-26 10:05:50 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. For more information, go to535 5.7.8  https://support.google.com/mail/?p=BadCredentials 38308e7fff4ca-30d7d7fe8b9sm21048361fa.58 - gsmtp<br>
SMTP Error: Could not authenticate.<br>
2025-03-26 10:05:50 CLIENT -&gt; SERVER: QUIT<br>
2025-03-26 10:05:50 SMTP INBOUND: &quot;221 2.0.0 closing connection 38308e7fff4ca-30d7d7fe8b9sm21048361fa.58 - gsmtp&quot;<br>
2025-03-26 10:05:50 SERVER -&gt; CLIENT: 221 2.0.0 closing connection 38308e7fff4ca-30d7d7fe8b9sm21048361fa.58 - gsmtp<br>
2025-03-26 10:05:50 Connection: closed<br>
Invalid hostentry:  <br>
SMTP Error: Could not authenticate.<br>
<!DOCTYPE html>
<html>

...