diff --git a/src/com/fsck/k9/mail/internet/MimeMessage.java b/src/com/fsck/k9/mail/internet/MimeMessage.java index 8eb3dfe95..857d1ad76 100644 --- a/src/com/fsck/k9/mail/internet/MimeMessage.java +++ b/src/com/fsck/k9/mail/internet/MimeMessage.java @@ -2,6 +2,7 @@ package com.fsck.k9.mail.internet; import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -14,6 +15,7 @@ import java.util.Locale; import java.util.Set; import java.util.UUID; +import org.apache.commons.io.IOUtils; import org.apache.james.mime4j.MimeException; import org.apache.james.mime4j.dom.field.DateTimeField; import org.apache.james.mime4j.field.DefaultFieldParser; @@ -575,6 +577,10 @@ public class MimeMessage extends Message { @Override public void epilogue(InputStream is) throws IOException { + expect(MimeMultipart.class); + ByteArrayOutputStream epilogue = new ByteArrayOutputStream(); + IOUtils.copy(is, epilogue); + ((MimeMultipart) stack.peek()).setEpilogue(epilogue.toByteArray()); } @Override diff --git a/src/com/fsck/k9/mail/internet/MimeMultipart.java b/src/com/fsck/k9/mail/internet/MimeMultipart.java index 124ca5e4c..6775fdaea 100644 --- a/src/com/fsck/k9/mail/internet/MimeMultipart.java +++ b/src/com/fsck/k9/mail/internet/MimeMultipart.java @@ -11,6 +11,7 @@ import java.util.Random; public class MimeMultipart extends Multipart { private String mPreamble; + private byte[] mEpilogue; private String mContentType; @@ -53,6 +54,10 @@ public class MimeMultipart extends Multipart { this.mPreamble = preamble; } + public void setEpilogue(byte[] epilogue) { + mEpilogue = epilogue; + } + @Override public String getContentType() { return mContentType; @@ -90,6 +95,9 @@ public class MimeMultipart extends Multipart { writer.write(mBoundary); writer.write("--\r\n"); writer.flush(); + if (mEpilogue != null) { + out.write(mEpilogue); + } } @Override diff --git a/tests/src/com/fsck/k9/mail/ReconstructMessageTest.java b/tests/src/com/fsck/k9/mail/ReconstructMessageTest.java index 1e6528c99..e36854354 100644 --- a/tests/src/com/fsck/k9/mail/ReconstructMessageTest.java +++ b/tests/src/com/fsck/k9/mail/ReconstructMessageTest.java @@ -42,7 +42,8 @@ public class ReconstructMessageTest extends AndroidTestCase { "VGhpcyBpcyBhIHRl\r\n" + "c3QgbWVzc2FnZQ==\r\n" + "\r\n" + - "------Boundary--\r\n"; + "------Boundary--\r\n" + + "Hi, I'm the epilogue"; BinaryTempFileBody.setTempDirectory(getContext().getCacheDir());