mirror of
https://github.com/nextcloud/server.git
synced 2026-02-25 19:04:38 -05:00
fix(imip): set charset for imip attachment
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
parent
ae4bbbf82b
commit
209ad4e780
1 changed files with 13 additions and 4 deletions
|
|
@ -249,7 +249,6 @@ class IMipPlugin extends SabreIMipPlugin {
|
|||
// convert iTip Message to string
|
||||
$itip_msg = $iTipMessage->message->serialize();
|
||||
|
||||
$user = null;
|
||||
$mailService = null;
|
||||
|
||||
try {
|
||||
|
|
@ -261,8 +260,14 @@ class IMipPlugin extends SabreIMipPlugin {
|
|||
$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(
|
||||
|
|
@ -274,10 +279,12 @@ class IMipPlugin extends SabreIMipPlugin {
|
|||
$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
|
||||
|
|
@ -293,10 +300,12 @@ class IMipPlugin extends SabreIMipPlugin {
|
|||
(($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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue