Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when sendig email report after upgrading to 4.11 #19633

Closed
x97-epe opened this issue Aug 16, 2022 · 7 comments
Closed

Error when sendig email report after upgrading to 4.11 #19633

x97-epe opened this issue Aug 16, 2022 · 7 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@x97-epe
Copy link

x97-epe commented Aug 16, 2022

After upgrading Matomo from 4.10.1 to 4.11.0 system fails sending email report.
System is configured to send email using PHP build in-mail function.
Email troubleshooting:

$ ./console core:test-email <myemailaddress>

succeed (no kind of error/warning, and email is regularly received). Instead sending report via admin web-page (Personal Email Reports => Send-Report-now) fails with generic error:

"An error occurred while sending 'HTML Email Report - 2.yesterday.1.en - XXXXX.html' to . Error was 'Could not instantiate mail function.'"

Original Matomo installation was 4.9 and then further updated. Problem is new since update to 4.11.0.
Please note:

  • Matomo runs on RHEL8 using PHP 7.4 (Apache 2.4 + PHP-FPM)
  • No errors/warning in PHP-FPM or Apache logs
  • No activity into local postfix used for forwarding email (no request received from PHP, but when running console test )

config.ini.php seems correct with expected config (including noreply_email_address) and Matomo diagnostic does not report any kind of problem.

Has such behavior been noticed by others? Any further troubleshooting step to be performed? In the way problem appeared it seems related to performed upgrade.

@bx80
Copy link
Contributor

bx80 commented Aug 17, 2022

Hi @x97-epe, thanks for reaching out.

If the console test-email command is successfully sending emails then it seems unlikely there is an issue with the Matomo email configuration. As far as I can see there haven't been any recent changes relating to mail delivery. I've also tested the 'Personal > Email Reports > Send Report Now' function and it's working for me.

"Could not instantiate mail function." is a generic message returned by PHPMailer when it is unable to deliver the mail to the system mail transport agent, which would match up with the lack of postfix activity.

A few things to try:

  • If you run the ./console core:test-email <myemailaddress> command as the same user as the webserver (eg. www-data) does it still succeed?
  • If you create a new simple email report with a simple name (eg. abc123) and attempt 'Send Report Now', does it succeed?
  • Do other emails sent from the Matomo UI work? Such as invite user or reset password?

@bx80 bx80 added the answered For when a question was asked and we referred to forum or answered it. label Aug 17, 2022
@x97-epe
Copy link
Author

x97-epe commented Aug 17, 2022

Hi bx80! Thanks for feedback.

It seems to me PHP and email sub-system (postfix) are properly configured and work. In fact:

  • ./console core:test-email works when using my email as well when sending to apache@localhost (end into (/var/spool/mail/root file).
  • I set a test email-report configured to be delivered at given time. I regularly get the report...

The problem seem to be connected to sending email via web-admin.

  • I cannot send report using "Send Report Now".
  • Reset Password and Invite new user routines fail

I actually find another similar report in forum when searching for "error crating new users":
https://forum.matomo.org/t/4-11-0-cant-set-new-user-passwords-but-user-invite-emails-not-sent/46954

It could be that email issues existed before 4.11, but we have not noticed it. I open present issue following a report my our web team complaining they failed to notify new users...

@bx80
Copy link
Contributor

bx80 commented Aug 19, 2022

Hi @x97-epe, thanks for the extra information 👍

I've checked the 'Send Report Now' and 'Invite User' web admin functions and they are using the same underlying code to send mail as the ./console core:test-email command. They both work consistently in my tests.

Typically the web server will not be running as the same Linux user as one used for scheduled reports (cronjob) and console commands, so different user permissions might an issue. From your tests we know that the PHP mail() command and system mail subsystem are working, it would be good to also confirm that the web server user can successfully send test emails.

Could you try to run the test email command as the web server user? (assuming the web server user is apache2 on RHEL)

sudo -u apache2 ./console core:test-email <myemailaddress>

@x97-epe
Copy link
Author

x97-epe commented Aug 19, 2022

Hi!

I double check and process for httpd and php-fpm on RHEL8 run as user "apache". I run

sudo -u apache ./console core:test-email <myemail>

And it worked as expected.

@x97-epe
Copy link
Author

x97-epe commented Aug 19, 2022

Ok... I got it! It was SELINUX...

So obvious (now), but somehow I miss it. I finally noticed the logs generated into audit logs, I set SELINUX in permissive mode and emails are now sent via web... When set SEpolicy "httpd_can_sendmail" it works also with enable (enforcing) SELinux. Problem happened since such config was supposed to be already fix on server ("bug" into Ansible playbook script), and we notice issue at "wrong time" (i.e. right after Matomo update)

No problem with Matomo, case closed.
Thanks!

@sgiehl sgiehl closed this as completed Aug 20, 2022
@bx80
Copy link
Contributor

bx80 commented Aug 21, 2022

Glad you got it sorted! Thanks for letting us know 🙂

@MatomoForumNotifications

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/matomo-no-send-mail-for-invite-a-new-user/50150/4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

4 participants