diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index be238ae5afbda..dd6bd9d99d1f5 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -268,12 +268,18 @@ public function schedule(Message $iTipMessage) { $message->useTemplate($template); - $attachment = $this->mailer->createAttachment( - $iTipMessage->message->serialize(), - 'event.ics',// TODO(leon): Make file name unique, e.g. add event id - 'text/calendar; method=' . $iTipMessage->method + /* + ** We choose to work like Thunderbird Lightning. + ** using a plain text text/calendar ics. + ** This plain text text/calendar part is needed for + ** Microsoft Outlook versions <= 2010 to work. + */ + $itip_msg = $iTipMessage->message->serialize(); + $message->attachInline( + $itip_msg, + 'text/calendar; method=' . $iTipMessage->method, + 'UTF-8' ); - $message->attach($attachment); try { $failed = $this->mailer->send($message); diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php index 3313b39e2e2be..8ed9c3a275a72 100644 --- a/lib/private/Mail/Message.php +++ b/lib/private/Mail/Message.php @@ -64,6 +64,30 @@ public function attach(IAttachment $attachment): IMessage { return $this; } + /** + * Can be used to "attach content inline" as message parts with specific MIME type and encoding. + * + * @param $body: body of the MIME part + * @param $content-type: MIME Content-Type (e.g. text/plain or text/calendar) + * @param $charset: Character Set (e.g. UTF-8) + * @return IMessage + * @since 26.0.0 + */ + public function attachInline(string $body, string $contentType = null, string $charset = null): IMessage { + # To be sure this works with iCalendar messages, we encode with 8bit instead of + # quoted-printable encoding. We save the current encoder, replace the current + # encoder with an 8bit encoder and after we've finished, we reset the encoder + # to the previous one. Originally intended to be added after the message body, + # as it is curently unknown if all mail clients handle this properly if added + # before. + $encoder = $this->swiftMessage->getEncoder(); + $eightbitEncoder = new \Swift_Mime_ContentEncoder_PlainContentEncoder('8bit'); + $this->swiftMessage->setEncoder($eightbitEncoder); + $this->swiftMessage->addPart($body, $contentType, $charset); + $this->swiftMessage->setEncoder($encoder); + return $this; + } + /** * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains * FIXME: Remove this once SwiftMailer supports IDN diff --git a/lib/public/Mail/IMessage.php b/lib/public/Mail/IMessage.php index 994d32603e93a..cfb900288a9b0 100644 --- a/lib/public/Mail/IMessage.php +++ b/lib/public/Mail/IMessage.php @@ -40,6 +40,17 @@ interface IMessage { */ public function attach(IAttachment $attachment): IMessage; + /** + * Can be used to "attach content inline" as message parts with specific MIME type and encoding. + * + * @param $body: body of the MIME part + * @param $content-type: MIME Content-Type (e.g. text/plain or text/calendar) + * @param $charset: Character Set (e.g. UTF-8) + * @return IMessage + * @since 26.0.0 + */ + public function attachInline(string $body, string $contentType = null, string $charset = null): IMessage; + /** * Set the from address of this message. *