From 987700cd8732d3c5fb7adb2c9232dcf271ba5d52 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 23 Oct 2015 14:34:19 -0400 Subject: [PATCH] (fix) inline images sent from SOGo webmail are not displayed in Mozilla Thunderbird (#3271) --- NEWS | 1 + SoObjects/Mailer/SOGoDraftObject.m | 30 ++++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 9271e0c1a..8366f624e 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ Bug fixes - don't escape quoted strings during versit generation - we now return all cards when we receive an empty addressbook-query REPORT - avoid crash when replying to a mail with no recipients (#3359) + - inline images sent from SOGo webmail are not displayed in Mozilla Thunderbird (#3271) 2.3.2 (2015-09-16) ------------------ diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index 471914ab6..410e8004c 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -181,6 +181,7 @@ static NSString *headerKeys[] = {@"subject", @"to", @"cc", @"bcc", static NGMimeType *MultiMixedType = nil; static NGMimeType *MultiAlternativeType = nil; +static NGMimeType *MultiRelatedType = nil; static NSString *userAgent = nil; + (void) initialize @@ -191,6 +192,9 @@ static NSString *userAgent = nil; MultiAlternativeType = [NGMimeType mimeType: @"multipart" subType: @"alternative"]; [MultiAlternativeType retain]; + MultiRelatedType = [NGMimeType mimeType: @"multipart" subType: @"related"]; + [MultiRelatedType retain]; + userAgent = [NSString stringWithFormat: @"SOGoMail %@", SOGoVersion]; [userAgent retain]; @@ -1677,16 +1681,20 @@ static NSString *userAgent = nil; NGMimeMessage *message; NGMutableHashMap *map; NSString *newText; + BOOL has_inline_images; message = nil; - + has_inline_images = NO; bodyParts = [NSMutableArray array]; if (_extractImages) { newText = [text htmlByExtractingImages: bodyParts]; if ([bodyParts count]) - [self setText: newText]; + { + [self setText: newText]; + has_inline_images = YES; + } } map = [self mimeHeaderMapWithHeaders: _headers @@ -1703,10 +1711,20 @@ static NSString *userAgent = nil; /* no attachments */ message = [self mimeMessageForContentWithHeaderMap: map]; else - /* attachments, create multipart/mixed */ - message = [self mimeMultiPartMessageWithHeaderMap: map - andBodyParts: bodyParts]; - //[self debugWithFormat: @"message: %@", message]; + { + // attachments, create multipart/mixed or multipart/related if + // we have inline image to avoid Thunderbird bug #61815 (https://bugzilla.mozilla.org/show_bug.cgi?id=61815) + if (has_inline_images) + { + [map removeAllObjectsForKey: @"content-type"]; + [map addObject: MultiRelatedType forKey: @"content-type"]; + } + + message = [self mimeMultiPartMessageWithHeaderMap: map + andBodyParts: bodyParts]; + + //[self debugWithFormat: @"message: %@", message]; + } } return message;