Okay, I've worked out the problem.

The POP3 Hander in James is using MimeMessage's getSize() method to obtain the size of 
the message to be returned - this returns the size of the message content not 
including headers.  However, I've telnetted into some other POP3 servers, and they 
return the size of the message and the headers.  So, I enclose below, some patches to 
fix this - I've tested them and they seem to be working fine.

Stuart.


> In case the last post wastes someone's time following false leads, I've just 
>manually 
> telnetted into the POP3 server and established that the mail that is not downloading 
>is 
> currently being "LIST"ed as 0 bytes long, but appears to have length when I view the 
>files in 
> my mailbox directory.  I will pursue... 
>  
> Stuart. 
>  
> On Wednesday, November 29, 2000, at 09:27 AM, Stuart Roebuck wrote: 
>  
> > I'm not sure whether this is JAMES or my mail client (I've not had problems with 
>my client in  
> > the past and it hasn't changed since MacOS X Beta arrived a few months ago).  
> >   
> > I'm now running the latest original Avalon CVS of JAMES.  
> >   
> > I've found that a small number of emails (currently 3 - earlier 1) are being left 
>on the  
> > server (James) by my email client when I check (and delete from server) my mail.  
>I don't  
> > think these emails are ever downloaded.  They *have* been corrected sorted into my 
> mailbox  
> > sub-directory.  
> >   
> > It is as if my client thinks it has already downloaded them in the past.  
> >   
> > I'm not familiar at all with the protocols used to communicate between an email 
>client and  
> > POP3 server.  I imagine that every new mail is either timestamped with an arrival 
>time, or  
> > given a consecutive ID number, by which the client can identify a new email.  Is 
>there any 
> way  
> > that this mechanism could be failing in James?  What about situations where mail 
>folders  
> > are wiped manually when James is (or isn't) running?  Or what if a machine's 
>automatic  
> > Internet time re-alignment mechanism coincides with mail arrivals so that time 
>appears  
> > to go backwards for a very short period of time?  
> >   
> > Thanks,  
> >   
> > Stuart.  
>  


Add to MailImpl.java

    /**
     * <p>Return the full size of the message including its headers.
     * MimeMessage.getSize() method only returns the size of the message
     * body.</p>
     *
     * <p>Note: this size is not guaranteed to be accurate - see Sun's
     * documentation of MimeMessage.getSize().</p>
     *
     * @return approximate size of full message including headers.
     *
     * @author Stuart Roebuck <[EMAIL PROTECTED]>
     */
    public int getFullMessageSize() throws MessagingException {
        int fullMessageSize = message.getSize();
        Enumeration e = this.message.getAllHeaders();
        while (e.hasMoreElements()) {
            fullMessageSize += ( (Header) e.nextElement()).toString().length();
        }
        return fullMessageSize;
    }


Patches for POP3Handler.java:

Index: POP3Handler.java
===================================================================
RCS file: /products/cvs/master/james/src/org/apache/james/pop3server/POP3Handler.java,v
retrieving revision 1.29
diff -u -r1.29 POP3Handler.java
--- POP3Handler.java    2000/10/19 02:20:15     1.29
+++ POP3Handler.java    2000/11/29 11:46:03
@@ -192,7 +192,7 @@
                     for (Enumeration e = userMailbox.elements(); e.hasMoreElements(); 
) {
                         MailImpl mc = (MailImpl) e.nextElement();
                         if (mc != DELETED) {
-                            size += mc.getMessage().getSize();
+                            size += mc.getFullMessageSize();
                             count++;
                         }
                     }
@@ -213,7 +213,7 @@
                         for (Enumeration e = userMailbox.elements(); 
e.hasMoreElements(); ) {
                             MailImpl mc = (MailImpl) e.nextElement();
                             if (mc != DELETED) {
-                                size += mc.getMessage().getSize();
+                                size += mc.getFullMessageSize();
                                 count++;
                             }
                         }
@@ -222,7 +222,7 @@
                         for (Enumeration e = userMailbox.elements(); 
e.hasMoreElements(); count++) {
                             MailImpl mc = (MailImpl) e.nextElement();
                             if (mc != DELETED) {
-                                out.println(count + " " + mc.getMessage().getSize());
+                                out.println(count + " " + mc.getFullMessageSize());
                             }
                         }
                         out.println(".");
@@ -235,7 +235,7 @@
                         num = Integer.parseInt(argument);
                         MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                         if (mc != DELETED) {
-                            out.println(OK_RESPONSE + " " + num + " " + 
mc.getMessage().getSize());
+                            out.println(OK_RESPONSE + " " + num + " " + 
+mc.getFullMessageSize());
                         } else {
                             out.println(ERR_RESPONSE + " Message (" + num + ") does 
not exist.");
                         }


** We are currently experiencing prolonged difficulties with our email **
** provider DIGIWEB and INTERLIANT.  To guarantee that your response   **
** is received, please replace "adolos.com" with "adolos.co.uk"        **
** in your response.                                                   **

-------------------------------------------------------------------------
Stuart Roebuck                                  [EMAIL PROTECTED]
Lead Developer                                  Mac OS X, Java, XML, etc.
ADOLOS                                             http://www.adolos.com/

------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives:  <http://www.mail-archive.com/james%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to