Skip to content
Merged
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
17 changes: 13 additions & 4 deletions apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ public function schedule(Message $iTipMessage) {
// convert iTip Message to string
$itip_msg = $iTipMessage->message->serialize();

$user = null;
$mailService = null;

try {
Expand All @@ -261,8 +260,14 @@ public function schedule(Message $iTipMessage) {
$mailService = $this->mailManager->findServiceByAddress($user->getUID(), $sender);
}
}

// The display name in Nextcloud can use utf-8.
// As the default charset for text/* is us-ascii, it's important to explicitly define it.
// See https://www.rfc-editor.org/rfc/rfc6047.html#section-2.4.
$contentType = 'text/calendar; method=' . $iTipMessage->method . '; charset="utf-8"';

// evaluate if a mail service was found and has sending capabilities
if ($mailService !== null && $mailService instanceof IMessageSend) {
if ($mailService instanceof IMessageSend) {
// construct mail message and set required parameters
$message = $mailService->initiateMessage();
$message->setFrom(
Expand All @@ -274,10 +279,12 @@ public function schedule(Message $iTipMessage) {
$message->setSubject($template->renderSubject());
$message->setBodyPlain($template->renderText());
$message->setBodyHtml($template->renderHtml());
// Adding name=event.ics is a trick to make the invitation also appear
// as a file attachment in mail clients like Thunderbird or Evolution.
$message->setAttachments((new Attachment(
$itip_msg,
null,
'text/calendar; name=event.ics; method=' . $iTipMessage->method,
$contentType . '; name=event.ics',
true
)));
// send message
Expand All @@ -293,10 +300,12 @@ public function schedule(Message $iTipMessage) {
(($senderName !== null) ? [$sender => $senderName] : [$sender])
);
$message->useTemplate($template);
// Using a different content type because Symfony Mailer/Mime will append the name to
// the content type header and attachInline does not allow null.
$message->attachInline(
$itip_msg,
'event.ics',
'text/calendar; method=' . $iTipMessage->method
$contentType,
);
$failed = $this->mailer->send($message);
}
Expand Down
Loading