OJS 3.1.2 SMTP Office 365

Hello,
I have a problem with OJS 3.1.2.1. SMTP server configured with O365 server. The system sends e-mails on the settings below, but the return address is ojs@domain.edu.
smtp_server = smtp.office365.com
smtp_port = 587
smtp_auth = tls
smtp_username = ojs@domain.edu
smtp_password = pass

allow_envelope_sender = On
default_envelope_sender = ojs@domain.edu
force_default_envelope_sender = On
force_dmarc_compliant_from = On

I would like the return address for a given journal to be the Principal Contact in a given journal, ie ojs-journal@domain.edu. The ojs-journal@domain.edu mailbox set up with permissions that the ojs@domain.edu account can send messages as ojs-journal@domain.edu and from it. Unfortunately it does not work. Log error:

SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message.

Regards, Krzysztof

Hello @krzysztof .
Do you have SSH?
Install swaks and…
Test this, if you want

swaks --to test@test.com -s smtp.office365.com:587 -tls -au ojs@domain.edu -ap PASSW*RD

Hello,
swaks --to test@gmail.com --from ojs-journal@domain.edu -s smtp.office365.com:587 -tls -au ojs@domain.edu -ap PASSW*RD

Succes!
Any suggestions?

Regards, Krzysztof

Hello @krzysztof , can you test…

Hello @juanito,
It doesn’t work…

Hello @krzysztof
Dou you test …

?

Microsoft/Office 365 E-mail service is in fact Exchange Online and does not support pop3/smtp protocols by default, but requires to be enabled by tenant admin. Also, it is not recommended to enable smtp authentication for all accounts, but only for account(s) that really need it (e.g. the account that is used for OJS to send notifications by e-mail).
More details are provided here: Enable or disable SMTP AUTH in Exchange Online | Microsoft Docs

If smtp is already enabled, there might be a problem with client authentication, check with tenant admin and topics like this one: Email authentication in Microsoft 365 - Office 365 | Microsoft Docs