diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index 3ff3ed0c5697a..cd3a9b9391d5c 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -244,12 +244,17 @@ public function schedule(Message $iTipMessage) { $template->addFooter(); $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->addPart( + $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 8a13e2c108cc7..79fc9928930e5 100644 --- a/lib/private/Mail/Message.php +++ b/lib/private/Mail/Message.php @@ -58,6 +58,26 @@ public function attach(IAttachment $attachment): IMessage { return $this; } + /** + * @param $body: body of the mime part + * @param $content-type = null: Mime Content-Type (e.g. text/plain or text/calendar) + * @param $charset = null: Character Set (e.g. UTF-8) + * @return $this + * @since 16.0.0 + */ + public function addPart($data, $content_type = null, $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. + $encoder = $this->swiftMessage->getEncoder(); + $eightbit_encoder = new \Swift_Mime_ContentEncoder_PlainContentEncoder("8bit"); + $this->swiftMessage->setEncoder($eightbit_encoder); + $this->swiftMessage->addPart($data, $content_type, $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 638fd9d103fc7..b4073bee535ef 100644 --- a/lib/public/Mail/IMessage.php +++ b/lib/public/Mail/IMessage.php @@ -39,6 +39,15 @@ interface IMessage { */ public function attach(IAttachment $attachment): IMessage; + /** + * @param $body: body of the mime part + * @param $content-type = null: Mime Content-Type (e.g. text/plain or text/calendar) + * @param $charset = null: Character Set (e.g. UTF-8) + * @return IMessage + * @since 16.0.0 + */ + public function addPart($body, $content_type = null, $charset = null): IMessage; + /** * Set the from address of this message. *