From 0c2e06133c4a877d8d1f50e8a8113842faac9091 Mon Sep 17 00:00:00 2001 From: Marcus Wolschon Date: Wed, 1 Jun 2011 09:13:16 +0200 Subject: [PATCH] http://code.google.com/p/k9mail/issues/detail?id=3408&sort=-id&colspec=ID%20Product%20Type%20Status%20Priority%20Milestone%20Owner%20Summary Issue 3408: SMTP timeouts while calculating message size --- src/com/fsck/k9/mail/transport/SmtpTransport.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/mail/transport/SmtpTransport.java b/src/com/fsck/k9/mail/transport/SmtpTransport.java index d718a777b..de204a1dd 100644 --- a/src/com/fsck/k9/mail/transport/SmtpTransport.java +++ b/src/com/fsck/k9/mail/transport/SmtpTransport.java @@ -352,11 +352,20 @@ public class SmtpTransport extends Transport { // If the message has attachments and our server has told us about a limit on // the size of messages, count the message's size before sending it if (mLargestAcceptableMessage > 0 && ((LocalMessage)message).hasAttachments()) { - if (message.calculateSize() > mLargestAcceptableMessage) { + if (K9.DEBUG_PROTOCOL_SMTP) { + Log.d(K9.LOG_TAG, "calculating message size"); + } + close(); // (prevent timeouts while calculating the size) + final long calculatedSize = message.calculateSize(); + if (calculatedSize > mLargestAcceptableMessage) { MessagingException me = new MessagingException("Message too large for server"); me.setPermanentFailure(possibleSend); throw me; } + open(); // (prevent timeouts while calculating the size) + if (K9.DEBUG_PROTOCOL_SMTP) { + Log.d(K9.LOG_TAG, "calculating message size DONE size=" + calculatedSize + " max allowed=" + mLargestAcceptableMessage); + } } Address[] from = message.getFrom();