diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index f15ea34ae..9077e6d87 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -1139,10 +1139,8 @@ public class LocalStore extends Store implements Serializable { LocalMessage localMessage = (LocalMessage)message; Cursor cursor = null; - localMessage.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "multipart/mixed"); MimeMultipart mp = new MimeMultipart(); mp.setSubType("mixed"); - localMessage.setBody(mp); try { cursor = mDb.rawQuery("SELECT html_content, text_content FROM messages " @@ -1232,6 +1230,18 @@ public class LocalStore extends Store implements Serializable cursor.close(); } } + + if (mp.getCount() == 1) + { + BodyPart part = mp.getBodyPart(0); + localMessage.setHeader(MimeHeader.HEADER_CONTENT_TYPE, part.getContentType()); + localMessage.setBody(part.getBody()); + } + else + { + localMessage.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "multipart/mixed"); + localMessage.setBody(mp); + } } } } diff --git a/src/com/fsck/k9/mail/transport/SmtpTransport.java b/src/com/fsck/k9/mail/transport/SmtpTransport.java index 53002f256..afdecabf9 100644 --- a/src/com/fsck/k9/mail/transport/SmtpTransport.java +++ b/src/com/fsck/k9/mail/transport/SmtpTransport.java @@ -304,10 +304,11 @@ public class SmtpTransport extends Transport } message.setRecipients(RecipientType.BCC, null); executeSimpleCommand("DATA"); - // TODO byte stuffing - message.writeTo( - new EOLConvertingOutputStream( - new BufferedOutputStream(mOut, 1024))); + EOLConvertingOutputStream msgOut = new EOLConvertingOutputStream( + new BufferedOutputStream(mOut, 1024)); + message.writeTo(msgOut); + // We use BufferedOutputStream. So make sure to call flush() ! + msgOut.flush(); possibleSend = true; // After the "\r\n." is attempted, we may have sent the message executeSimpleCommand("\r\n.");