Currently OLAT does always set the From header of outgoing mails to the configured "fromMail" property, puts the sending olat users mail address in the reply-to header and does also set the smtpFrom to this reply-to address.
Bounce messages are being sent to the smtpFrom, but unfortunately MS Exchange always sends out of office to the address in the From header (ignoring reply-to and return-path).
The attached patch introduces a new property "fromDomain" which does introduce a new logic for setting the "From" mail header for outgoing mails:
A Mail Address is considered external when it ends with the configured "fromDomain" property. If the "fromDomain" property is not set, all mail addresses are considered external.
When the sending olat users mail address is an external one AND at least ONE of the recipients mail address in an external address the From header will be set as before to prevent SPAM detection or rejects because of SPF violation.
Otherwise (either the sending olat users mail address is not external or all the recipients addresses are not external) the "From" mail header will be set to the sending olat users mail address.
This patch also undoes the previous patch (setting the smtpFrom to the replyTo header) as it is not needed anymore and setting the smtpFrom to an external Maildomain can lead to problems when sending a mail to a recipient with an address of that Maildomain. (e.g. the External SMTP Server requiring password authentication).