Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions redaxo/src/addons/phpmailer/lib/mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,31 @@ protected function microsoft365Send(): bool
}

$customHeaders = [];
$extendedProperties = [];
/** @var array{string, string} $header */
foreach ($this->getCustomHeaders() as $header) {
$customHeaders[] = [
'name' => $header[0],
'value' => $this->encodeHeader(trim($header[1])),
];
$name = trim($header[0]);
$value = trim($header[1]);

if (str_starts_with(strtolower($name), 'x-')) {
$customHeaders[] = [
'name' => $name,
'value' => $this->encodeHeader($value),
];
continue;
}

if ('list-unsubscribe' === strtolower($name)) {
// MAPI property PidTagListUnsubscribe; Exchange emits it as List-Unsubscribe header
$extendedProperties[] = [
'id' => 'String 0x1045',
'value' => $value,
];
continue;
}

// The Graph API rejects the whole request for custom headers without "x-" prefix,
// so headers without a MAPI mapping (e.g. Auto-Submitted) have to be dropped
}

// Attachments für Graph API aufbereiten
Expand Down Expand Up @@ -470,6 +489,9 @@ protected function microsoft365Send(): bool
if (!empty($customHeaders)) {
$mailData['message']['internetMessageHeaders'] = $customHeaders;
}
if (!empty($extendedProperties)) {
$mailData['message']['singleValueExtendedProperties'] = $extendedProperties;
}
if ('' !== $this->ConfirmReadingTo) {
// MS Graph API unterstützt keine Read-Receipts an beliebige Empfänger
$mailData['message']['isReadReceiptRequested'] = true;
Expand Down
Loading