Skip to content

Commit 9e53934

Browse files
authored
Merge pull request #36118 from nextcloud/fix/caldav/invitation-outlook-compatibilty
Fix calendar emails to be outlook compatible
2 parents 14cb58c + ed70815 commit 9e53934

3 files changed

Lines changed: 32 additions & 6 deletions

File tree

apps/dav/lib/CalDAV/Schedule/IMipPlugin.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,12 @@ public function schedule(Message $iTipMessage) {
299299

300300
$message->useTemplate($template);
301301

302-
$vCalendar = $this->imipService->generateVCalendar($iTipMessage, $vEvent);
303-
304-
$attachment = $this->mailer->createAttachment(
305-
$vCalendar->serialize(),
302+
$itip_msg = $iTipMessage->message->serialize();
303+
$message->attachInline(
304+
$itip_msg,
306305
'event.ics',
307-
'text/calendar; method=' . $iTipMessage->method
306+
'text/calendar; method=' . $iTipMessage->method,
308307
);
309-
$message->attach($attachment);
310308

311309
try {
312310
$failed = $this->mailer->send($message);

lib/private/Mail/Message.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,22 @@ public function attach(IAttachment $attachment): IMessage {
7575
return $this;
7676
}
7777

78+
/**
79+
* Can be used to "attach content inline" as message parts with specific MIME type and encoding.
80+
* {@inheritDoc}
81+
* @since 26.0.0
82+
*/
83+
public function attachInline(string $body, string $name, string $contentType = null): IMessage {
84+
# To be sure this works with iCalendar messages, we encode with 8bit instead of
85+
# quoted-printable encoding. We save the current encoder, replace the current
86+
# encoder with an 8bit encoder and after we've finished, we reset the encoder
87+
# to the previous one. Originally intended to be added after the message body,
88+
# as it is curently unknown if all mail clients handle this properly if added
89+
# before.
90+
$this->symfonyEmail->embed($body, $name, $contentType);
91+
return $this;
92+
}
93+
7894
/**
7995
* Converts the [['displayName' => 'email'], ['displayName2' => 'email2']] arrays to valid Adresses
8096
*

lib/public/Mail/IMessage.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ interface IMessage {
3939
*/
4040
public function attach(IAttachment $attachment): IMessage;
4141

42+
/**
43+
* Can be used to "attach content inline" as message parts with specific MIME type and encoding.
44+
*
45+
* @param string $body body of the MIME part
46+
* @param string $name the file name
47+
* @param string|null $contentType MIME Content-Type (e.g. text/plain or text/calendar)
48+
*
49+
* @return IMessage
50+
* @since 26.0.0
51+
*/
52+
public function attachInline(string $body, string $name, string $contentType = null): IMessage;
53+
4254
/**
4355
* Set the from address of this message.
4456
*

0 commit comments

Comments
 (0)