Help with SMTP Setup - Office 365

Hello,

We are having trouble getting Piwik to send emails via our SMTP server - Office 365

We are using the “Forgot Password” function to test sending emails, but are getting these errors for the different configurations below:

SMTP server address: smtp.office365.com
SMTP Port: 587
Authentication method for SMTP: Login
SMTP username: the username
SMTP password: the password

And the errors:
SMTP encryption: TLS (Recommended by Microsoft)

Error: 5.7.60 SMTP; Client does not have permissions to send as this sender Possible reason: your host may have disabled the mail() function.
Please contact your Piwik administrator.

We also tried:
SMTP encryption: SSL

Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. Possible reason: your host may have disabled the mail() function.
Please contact your Piwik administrator.

In both cases, the error mentioned: Possible reason: your host may have disabled the mail() function.

I did a search on this online, found a lot of people asking how to enable it but no answers as to how.

We have Piwik hosted on IIS 8.5, installed by the Microsoft Web Platform Installer with PHP 5.6.0. The few mail settings in php.ini have not been modified, but really they shouldn’t make a difference anyway as we are specifying the account information in Piwik.

The issue here has to be with either our host or Piwik as we have validated the SMTP details work fine.

Can anyone offer any thoughts as to how we can get this working?

Thank you

EDIT: It appears as though the mail function is actually enabled already (see attached image).

This is no issue with the mail function, it is an issue with that: “Client does not have permissions to send as this sender”.
No idea as what matomo is trying to send the email, but there should be an option added to set the “FROM” address. If you try to send an email to office365 and your “from” address does not match the user (or one his aliases) you are logging in as, the email will not be sent.

Matomo sets the from email address as
config/global.ini.php:noreply_email_address = “noreply@{DOMAIN}”

The global config file says that you should overwrite those defaults in the config.ini.php, however I have found that this again is automatically created by Matomo every time you change some settings and thus renders it even more worthless than the global config template that only updates when you update Matomo.

So I have found no RELIABLE way of changing the FROM address.
Best way is to set it in config/global.ini.php and then remember to change it again every time you update Matomo.

Apparently no UI to set those values. I’d call this a bug.