While investigating issue Reports do not send whilst set to a daily basis · Issue #1961 · matomo-org/matomo · GitHub I found that the one test report that our user created is not sent to him, but to me, the super-user.
But this report doesn’t have my address as the recipient. The only thing in it that’s checked is the “send to me” checkbox and the value showing for “me” is the correct email address of the user. But it gets sent to me. This is not an issue of wrong mail routing. When sent manually the correct address is used.
I double-checked that the table piwik_pdf has the same information that shows in Piwik GUI - it does.
So, somehow when the job is done via cron it uses the super-user email and not the email that is configured in the report.
I assume this is somehow connected to archive.sh as this uses the super-user token-auth. There must be an array hanging around that contains the super-user email and that is then mistakenly used instead of the one that is attached to the report record.