Send email by office 365

Hello, I have an issue with matomo when I try to send reports with email by office 365 email account. It works for gmail but not for office 365. On same server I use PHPmailer with the same configuration and it works well. So the issue is only with matomo. Please find below details for the error reported. Your help is appreciated.

(email account is different in the original error)

An error occurred while sending ‘HTML Email Report - 3.yesterday.1.en - noR6TXG1pN1LTbjhTFAE47an68Jtx7LY5tOvplQT.html’ to user.name@companydomainname.com. Error was ‘5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:B0130000, 17.43559:0000000004020000000000000000000000000000, 20.52176:140F1587000010100A00FB7F, 20.50032:140F1587701710100A00FC7F, 0.35180:84180000, 255.23226:0A001137, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A000000, 16.55847:C4000000, 17.43559:00000000E0020000000000000100000000000000, 20.52176:140F15870000101003000136, 20.50032:140F1587701710100A00DA36, 0.35180:44000000, 255.23226:4800D13D, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:0A003A66, 4.21921:DC040000, 255.27962:FA000000, 255.1494:64000000, 0.38698:0F010480, 0.37692:1A010480, 0.37948:00400600, 5.33852:00000000534D545000010480, 4.56248:DC040000, 7.40748:010000000000010B30303A4D, 7.57132:00000000000000003A306535, 1.63016:32000000, 4.39640:DC040000, 8.45434:D7528821DBA69C4383A63437D4727ED500000000, 5.10786:0000000031352E32302E3138’

Emal setings as below:
smtp.office365.com
587
Login
user.name@companydomainname.com
TLS

Hi,

I looked for the (really vague) error message and it seems like there is a logical reason for this error:

Your mailserver doesn’t allow you to send E-Mails from the From: adress Matomo is trying to use.

So you should set the following in the [General] section of your config.ini.php:

login_password_recovery_email_address = "matomo@example.com"
noreply_email_address = "matomo@example.com"

with the E-Mail sender you are allowed to use.
https://matomo.org/faq/how-to/faq_18336/
https://matomo.org/faq/how-to/faq_109/

Thank you Lukas. It solved the issue. Thank you for quick reply.

1 Like

Hi all,

I’ve same error:

An error occurred while sending ‘HTML Email Report - 3.2022-01-25,2022-01-31.2.fr - GfOvpwd2Ev3QwSldj7Co5HfOZglwXQr6vjwerAh1.html’ to . Error was ‘Error SMTP : authentication failure.’

SMTP Settings :

SMTP Server Address : smtp.office365.com (tested with outlook.office365.com)
SMTP Port : 587
SMTP Auth metode : Login (tested with plain and cram-MD5)
SMTP User Name : email@domain.com
SMTP Password : *********
SMTP original address : email@domain.com
SMTP original name : email
SMTP encryption : auto (tested with SSL and TLS)

I’ve set to my config.ini.php :

login_password_recovery_email_address = "email@domain.com"
noreply_email_address = "email@domain.com"

This is my first time to try send smtp email with office365 (new user)

SOLVED

Add https://docs.microsoft.com/fr-fr/ for each link

1st : Enable basic authentification : exchange/clients-and-mobile-in-exchange-online/disable-basic-authentication-in-exchange-online
If you’re enable default security, disabled it before enable basic authentification : azure/active-directory/fundamentals/concept-fundamentals-security-defaults

NOTICE : Disable basic authentication for admin users !

More detail here : exchange/clients-and-mobile-in-exchange-online/enable-or-disable-modern-authentication-in-exchange-online

2nd : Enable SMTP AUTH to mailbox you want to send message with SMTP : exchange/clients-and-mobile-in-exchange-online/authenticated-client-smtp-submission

3th : Configure application to use SMTP Office 365 (use one of there options) : exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-microsoft-365-or-office-365