Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix calendar emails to be outlook compatible #36118

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 4 additions & 6 deletions apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,12 @@ public function schedule(Message $iTipMessage) {

$message->useTemplate($template);

$vCalendar = $this->imipService->generateVCalendar($iTipMessage, $vEvent);

$attachment = $this->mailer->createAttachment(
$vCalendar->serialize(),
$itip_msg = $iTipMessage->message->serialize();
$message->attachInline(
$itip_msg,
'event.ics',
'text/calendar; method=' . $iTipMessage->method
'text/calendar; method=' . $iTipMessage->method,
);
$message->attach($attachment);

try {
$failed = $this->mailer->send($message);
Expand Down
16 changes: 16 additions & 0 deletions lib/private/Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ public function attach(IAttachment $attachment): IMessage {
return $this;
}

/**
* Can be used to "attach content inline" as message parts with specific MIME type and encoding.
* {@inheritDoc}
* @since 26.0.0
*/
public function attachInline(string $body, string $name, string $contentType = 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.
$this->symfonyEmail->embed($body, $name, $contentType);
return $this;
}

/**
* Converts the [['displayName' => 'email'], ['displayName2' => 'email2']] arrays to valid Adresses
*
Expand Down
12 changes: 12 additions & 0 deletions lib/public/Mail/IMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ 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 string $body body of the MIME part
* @param string $name the file name
* @param string|null $contentType MIME Content-Type (e.g. text/plain or text/calendar)
*
* @return IMessage
* @since 26.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

27

*/
public function attachInline(string $body, string $name, string $contentType = null): IMessage;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?string $contentType = null


/**
* Set the from address of this message.
*
Expand Down