diff options
-rw-r--r-- | framework/src/domain/mime/mailtemplates.cpp | 15 | ||||
-rw-r--r-- | framework/src/domain/mime/tests/mailtemplatetest.cpp | 16 |
2 files changed, 25 insertions, 6 deletions
diff --git a/framework/src/domain/mime/mailtemplates.cpp b/framework/src/domain/mime/mailtemplates.cpp index 0380fa5c..4a8778f2 100644 --- a/framework/src/domain/mime/mailtemplates.cpp +++ b/framework/src/domain/mime/mailtemplates.cpp | |||
@@ -970,15 +970,18 @@ KMime::Message::Ptr MailTemplates::createMessage(KMime::Message::Ptr existingMes | |||
970 | 970 | ||
971 | KMime::Content *bodyPart; | 971 | KMime::Content *bodyPart; |
972 | if (!attachments.isEmpty()) { | 972 | if (!attachments.isEmpty()) { |
973 | mail->contentType(true)->setMimeType("multipart/mixed"); | 973 | bodyPart = new KMime::Content; |
974 | mail->contentType()->setBoundary(KMime::multiPartBoundary()); | 974 | bodyPart->contentType(true)->setMimeType("multipart/mixed"); |
975 | mail->contentTransferEncoding()->setEncoding(KMime::Headers::CE7Bit); | 975 | bodyPart->contentType()->setBoundary(KMime::multiPartBoundary()); |
976 | mail->setPreamble("This is a multi-part message in MIME format.\n"); | 976 | bodyPart->contentTransferEncoding()->setEncoding(KMime::Headers::CE7Bit); |
977 | bodyPart->setPreamble("This is a multi-part message in MIME format.\n"); | ||
978 | bodyPart->addContent(createBodyPart(body.toUtf8())); | ||
977 | for (const auto &attachment : attachments) { | 979 | for (const auto &attachment : attachments) { |
978 | mail->addContent(createAttachmentPart(attachment.data, attachment.filename, attachment.isInline, attachment.mimeType, attachment.name)); | 980 | bodyPart->addContent(createAttachmentPart(attachment.data, attachment.filename, attachment.isInline, attachment.mimeType, attachment.name)); |
979 | } | 981 | } |
982 | } else { | ||
983 | bodyPart = createBodyPart(body.toUtf8()); | ||
980 | } | 984 | } |
981 | bodyPart = createBodyPart(body.toUtf8()); | ||
982 | mail->assemble(); | 985 | mail->assemble(); |
983 | 986 | ||
984 | KMime::Content *signedResult = nullptr; | 987 | KMime::Content *signedResult = nullptr; |
diff --git a/framework/src/domain/mime/tests/mailtemplatetest.cpp b/framework/src/domain/mime/tests/mailtemplatetest.cpp index e814f75f..50d2d869 100644 --- a/framework/src/domain/mime/tests/mailtemplatetest.cpp +++ b/framework/src/domain/mime/tests/mailtemplatetest.cpp | |||
@@ -213,6 +213,7 @@ private slots: | |||
213 | qWarning().noquote() << result->encodedContent(); | 213 | qWarning().noquote() << result->encodedContent(); |
214 | qWarning() << "---------------------------------"; | 214 | qWarning() << "---------------------------------"; |
215 | QCOMPARE(result->subject()->asUnicodeString(), subject); | 215 | QCOMPARE(result->subject()->asUnicodeString(), subject); |
216 | QVERIFY(result->date(false)->dateTime().isValid()); | ||
216 | QVERIFY(result->contentType()->isMimeType("multipart/signed")); | 217 | QVERIFY(result->contentType()->isMimeType("multipart/signed")); |
217 | 218 | ||
218 | const auto contents = result->contents(); | 219 | const auto contents = result->contents(); |
@@ -243,7 +244,22 @@ private slots: | |||
243 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, attachments, keys); | 244 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, attachments, keys); |
244 | 245 | ||
245 | QVERIFY(result); | 246 | QVERIFY(result); |
247 | QCOMPARE(result->subject()->asUnicodeString(), subject); | ||
248 | QVERIFY(result->date(false)->dateTime().isValid()); | ||
246 | QVERIFY(result->contentType()->isMimeType("multipart/signed")); | 249 | QVERIFY(result->contentType()->isMimeType("multipart/signed")); |
250 | |||
251 | const auto contents = result->contents(); | ||
252 | QCOMPARE(contents.size(), 2); | ||
253 | { | ||
254 | auto c = contents.at(0); | ||
255 | QVERIFY(c->contentType()->isMimeType("multipart/mixed")); | ||
256 | //1 text + 2 attachments | ||
257 | QCOMPARE(c->contents().size(), 3); | ||
258 | } | ||
259 | { | ||
260 | auto c = contents.at(1); | ||
261 | QVERIFY(c->contentType()->isMimeType("application/pgp-signature")); | ||
262 | } | ||
247 | } | 263 | } |
248 | }; | 264 | }; |
249 | 265 | ||