matomo-org / matomo-for-wordpress

Get a fully functioning Matomo Analytics for your WordPress. Star us on Github? +1. Matomo is the leading open alternative to Google Analytics that gives you full control over your data. Privacy is built-in. 100% data ownership, no one else can see your data. We love Pull Requests!
https://matomo.org
GNU General Public License v3.0
119 stars 25 forks source link

E-Mail Reports stopped working with upgrade from 4.x to 5.06 #1143

Closed Grid405 closed 4 months ago

Grid405 commented 5 months ago

Hi,

i have a weird issue with email reports not being sent with Matomo 5.0.6 and 5.0.8. I have a report which is scheduled to be sent weekly, but it doesn't get sent anymore, eventhough the cron jobs seem to get triggered.

When i try to send a report manually, i get a 500 back (in the Browser's Network Inspector) with the following error: Class 'PHPMailer\PHPMailer\PHPMailer' not found.

From the Log file:

Matomo: ERROR: Uncaught exception: Error: Class 'PHPMailer\\PHPMailer\\PHPMailer' not found in [path]/wp-content/plugins/matomo/classes/WpMatomo/Email.php:128\nStack trace:\n#0 [path]/wp-includes/class-wp-hook.php(288): $

Sending matomo emails in general seems to work, i sent a test email using the console tool and it worked fine, i got the test email in my mailbox and no errors occured.

I upgraded manually from Matomo 4.x a while ago to Matomo 5.0.6, after which the issue first appeared. I tried clearing Matomo cache and running the Updater manually, but it didn't fix the problem. There should be no leftover files from the 4.x installation, as i completely removed the old plugin directory and put the 5.0.6 directory in it's place.

Today i upgraded successfully to 5.0.8 using the automatic updater from the WordPress dashboard, but the error still occurs.

There's only one problem listed in the diagnostics tool, which is "Warning WP_Filesystem Initialized: No", because i restrict write permissions to the wp-content folder. I temporarily gave all the permissions to make sure this isn't the culprit and it wasn't (as expected, because write permissions shouldn't matter when reading files).

I'm out of ideas, why is Matomo not finding PHPMailer, is it a bug ?

diosmosis commented 5 months ago

Hi @Grid405, that is odd... can you check your WordPress installation for the following file: /path/to/wordpress/wp-includes/PHPMailer/PHPMailer.php? If it's there, can you check if the following text is in there (it will be near the top): namespace PHPMailer\PHPMailer;?

Grid405 commented 5 months ago

Hi, @diosmosis, i just checked, this directory doesn't exist. There's only a single file: /path/to/wordpress/wp-includes/class-php-mailer.php. Seems to be a compatibility issue, the installation in question is running WP 5.x.

diosmosis commented 5 months ago

That would do it. We'll be sure to fix this in the next release (which should be out in a week or so).