You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by "Noel J. Bergman" <no...@devtech.com> on 2002/07/10 17:08:24 UTC

RE: James <-> JavaMail notification

Robert,

You could write a notification mailet.  The nature of the notification
mechanism is up to you.

	--- Noel

-----Original Message-----
From: Robert Douglass [mailto:robert.douglass@hype.de]
Sent: Wednesday, July 10, 2002 9:03
To: Noel J. Bergman
Subject: AW: translation (JP)


No, I hadn't looked at the code. The 20-30 minutes that I've had so far to
research the matter didn't permit any in-depth analysis... therefore I asked
the list. Thank you for answering. How does one best achieve this type of
notification using JAMES? I haven't looked at the Mailet API yet, is that
where I should start? Is there any way to have JAMES communicate with my
JavaMail application when a new message arrives?

-Robert Douglass

-----Ursprungliche Nachricht-----
Von: Noel J. Bergman [mailto:noel@devtech.com]
Gesendet: Mittwoch, 10. Juli 2002 14:57
An: robert.douglass@hype.de
Betreff: RE: translation (JP)


Haven't you looked at the code?  James doesn't currently use JavaMail to
store messages.  How are you expecting the folder listener to work?

	--- Noel

-----Original Message-----
From: Robert Douglass [mailto:robert.douglass@hype.de]
Sent: Friday, July 05, 2002 4:53
To: James Users List
Subject: AW: translation (JP)


Hi James Users,
I'm trying to write a JavaMail application that notifies me when there is
new mail in my James inbox. My approach has been to register a
MailCountListener to the folder in a thread that keeps the folder connection
open:

folder.addMessageCountListener(new javax.mail.event.MessageCountListener() {
			public void messagesAdded(javax.mail.event.MessageCountEvent e) {
				System.out.println("You've got mail!");
			}

			public void messagesRemoved(javax.mail.event.MessageCountEvent e) {
				//do nothing
			}
		});

But, alas, it's not working. I know this isn't a JavaMail list, but I was
wondering if anybody has any advice, code examples, related experience to
help guide me.

Thanks,

Robert Douglass


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: James <-> JavaMail notification

Posted by Ramon Gonzalez <ra...@prarl.org>.
Here's a quick hack I did to check your email every 10 minutes. Just plug
your pop-server name, your userID and password.
You must download JavaMail and include in CLASSPATH
CheckMyEMail.java

/*
 * CheckMyEMail.java
 *
 * Created on July 10, 2002, 9:00 PM
 * @author Ramon Gonzalez
 */

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;

public class CheckMyEmail {

    public static void main(String args[])
    throws Exception {

        String pop3Host = "pop-server.tampabay.rr.com"; //pop host name
        String user = "userid"; //pop user Id
        String password = "password"; //POP Password
        int checkPeriod = 10; //checks inbox every x minutes

        CheckMyEmail checkMyEmail = new CheckMyEmail();

        while (true) { //loops every x minutes forever
            checkMyEmail.process(pop3Host, user, password);
            Thread.sleep(checkPeriod*1000*60); //sleep every x minutes
        }
    }

    /**  process() checks for new messages
     */

    public void process(String pop3Host, String user, String password)
    throws Exception {

        String INBOX = "INBOX";
        String POP_MAIL="pop3";

        try {

            // Get a Session object
            Properties sysProperties = System.getProperties();
            Session session = Session.getDefaultInstance(sysProperties,
null);
            session.setDebug(false); //set to true for session debug

            Store store = session.getStore(POP_MAIL);
            store.connect(pop3Host, -1, user, password);

            // Open the default folder
            Folder folder = store.getDefaultFolder();
            if (folder == null)
                throw new NullPointerException("No default mail folder");

            folder = folder.getFolder(INBOX);
            if (folder == null)
                throw new NullPointerException("Unable to get folder: " +
folder);

            // Get message count
            folder.open(Folder.READ_WRITE);
            int totalMessages = folder.getMessageCount();
            if (totalMessages == 0) {
                //System.out.println(folder + " is empty"); //use to see if
empty
            } else {
                System.out.println("You have Mail! There are " +
totalMessages+ " messages in your " + folder + " folder.");
            }

            folder.close(false);
            store.close();
            return;

        } catch (Exception e){
            System.out.println("Exception while checking email count.");
        }
    }
}


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: James <-> JavaMail notification

Posted by "Noel J. Bergman" <no...@devtech.com>.
Or you could write a mailet to send some sort of IM type notification, e.g.,
using Jabber or IRC on a private channel, over a socket, pager, etc.  All
sorts of things one could do.

	--- Noel

-----Original Message-----
From: Ramon Gonzalez [mailto:ramon@prarl.org]
Sent: Wednesday, July 10, 2002 20:04
To: James Users List
Cc: Robert Douglass
Subject: Re: James <-> JavaMail notification


There are 2 approaches...

You can write a Mailet that will do a System.out.println in the JAMES
console whenever an email with your user account name comes in.

Or you can wirite a JavaMail application that will connect via POP, look at
your default folder, and count how many emails you have and notify you.

A good article on how to write a simple Javamail client can be found at:
http://www.javaworld.com/javaworld/jw-06-1999/jw-06-javamail.html


________________________
Ramon Gonzalez
Tampa Bay, Florida


----- Original Message -----
From: "Noel J. Bergman" <no...@devtech.com>
To: "James-User Mailing List" <ja...@jakarta.apache.org>
Cc: "Robert Douglass" <ro...@hype.de>
Sent: Wednesday, July 10, 2002 11:08 AM
Subject: RE: James <-> JavaMail notification


> Robert,
>
> You could write a notification mailet.  The nature of the notification
> mechanism is up to you.
>
> --- Noel
>
> -----Original Message-----
> From: Robert Douglass [mailto:robert.douglass@hype.de]
> Sent: Wednesday, July 10, 2002 9:03
> To: Noel J. Bergman
> Subject: AW: translation (JP)
>
>
> No, I hadn't looked at the code. The 20-30 minutes that I've had so far to
> research the matter didn't permit any in-depth analysis... therefore I
asked
> the list. Thank you for answering. How does one best achieve this type of
> notification using JAMES? I haven't looked at the Mailet API yet, is that
> where I should start? Is there any way to have JAMES communicate with my
> JavaMail application when a new message arrives?
>
> -Robert Douglass
>
> -----Ursprungliche Nachricht-----
> Von: Noel J. Bergman [mailto:noel@devtech.com]
> Gesendet: Mittwoch, 10. Juli 2002 14:57
> An: robert.douglass@hype.de
> Betreff: RE: translation (JP)
>
>
> Haven't you looked at the code?  James doesn't currently use JavaMail to
> store messages.  How are you expecting the folder listener to work?
>
> --- Noel
>
> -----Original Message-----
> From: Robert Douglass [mailto:robert.douglass@hype.de]
> Sent: Friday, July 05, 2002 4:53
> To: James Users List
> Subject: AW: translation (JP)
>
>
> Hi James Users,
> I'm trying to write a JavaMail application that notifies me when there is
> new mail in my James inbox. My approach has been to register a
> MailCountListener to the folder in a thread that keeps the folder
connection
> open:
>
> folder.addMessageCountListener(new javax.mail.event.MessageCountListener()
{
> public void messagesAdded(javax.mail.event.MessageCountEvent e) {
> System.out.println("You've got mail!");
> }
>
> public void messagesRemoved(javax.mail.event.MessageCountEvent e) {
> //do nothing
> }
> });
>
> But, alas, it's not working. I know this isn't a JavaMail list, but I was
> wondering if anybody has any advice, code examples, related experience to
> help guide me.
>
> Thanks,
>
> Robert Douglass


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: James <-> JavaMail notification

Posted by Ramon Gonzalez <ra...@prarl.org>.
There are 2 approaches...

You can write a Mailet that will do a System.out.println in the JAMES
console whenever an email with your user account name comes in.

Or you can wirite a JavaMail application that will connect via POP, look at
your default folder, and count how many emails you have and notify you.

A good article on how to write a simple Javamail client can be found at:
http://www.javaworld.com/javaworld/jw-06-1999/jw-06-javamail.html


________________________
Ramon Gonzalez
Tampa Bay, Florida


----- Original Message -----
From: "Noel J. Bergman" <no...@devtech.com>
To: "James-User Mailing List" <ja...@jakarta.apache.org>
Cc: "Robert Douglass" <ro...@hype.de>
Sent: Wednesday, July 10, 2002 11:08 AM
Subject: RE: James <-> JavaMail notification


> Robert,
>
> You could write a notification mailet.  The nature of the notification
> mechanism is up to you.
>
> --- Noel
>
> -----Original Message-----
> From: Robert Douglass [mailto:robert.douglass@hype.de]
> Sent: Wednesday, July 10, 2002 9:03
> To: Noel J. Bergman
> Subject: AW: translation (JP)
>
>
> No, I hadn't looked at the code. The 20-30 minutes that I've had so far to
> research the matter didn't permit any in-depth analysis... therefore I
asked
> the list. Thank you for answering. How does one best achieve this type of
> notification using JAMES? I haven't looked at the Mailet API yet, is that
> where I should start? Is there any way to have JAMES communicate with my
> JavaMail application when a new message arrives?
>
> -Robert Douglass
>
> -----Ursprungliche Nachricht-----
> Von: Noel J. Bergman [mailto:noel@devtech.com]
> Gesendet: Mittwoch, 10. Juli 2002 14:57
> An: robert.douglass@hype.de
> Betreff: RE: translation (JP)
>
>
> Haven't you looked at the code?  James doesn't currently use JavaMail to
> store messages.  How are you expecting the folder listener to work?
>
> --- Noel
>
> -----Original Message-----
> From: Robert Douglass [mailto:robert.douglass@hype.de]
> Sent: Friday, July 05, 2002 4:53
> To: James Users List
> Subject: AW: translation (JP)
>
>
> Hi James Users,
> I'm trying to write a JavaMail application that notifies me when there is
> new mail in my James inbox. My approach has been to register a
> MailCountListener to the folder in a thread that keeps the folder
connection
> open:
>
> folder.addMessageCountListener(new javax.mail.event.MessageCountListener()
{
> public void messagesAdded(javax.mail.event.MessageCountEvent e) {
> System.out.println("You've got mail!");
> }
>
> public void messagesRemoved(javax.mail.event.MessageCountEvent e) {
> //do nothing
> }
> });
>
> But, alas, it's not working. I know this isn't a JavaMail list, but I was
> wondering if anybody has any advice, code examples, related experience to
> help guide me.
>
> Thanks,
>
> Robert Douglass
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Too Many Open Files

Posted by Stephan Schiessling <s...@rapi.com>.
There was a bug in MimeMessageSource (InputStreams were not closed), which was fixed in May.
Try to use a newer version of James.

Stephan


Stephen wrote:
>   Hello,
> 
>   Running James 2.0a2 on Windows 2000, using the filesystem as the 
> repository. When there are lots of messages for a user (problem 
> is seen somewhere between roughly 1000-2000 messages),  an error is
> returned when the user tries to retrieve these messages via POP. 
> 
>   From the server logs, this error appears to have something to do with
> "too many open files".
> 
>   When I last saw this, I stopped James and moved (the newest) 1/2 of the
> files from the user's inbox folder to a temporary folder. Restarted James,
> and was able to download the oldest messages. I then stopped James,
> restored the files from the temporary folder back to the inbox, and was now
> able to download these newest messages.
> 
>   Is this a known issue? Is there anything I can do to avoid the problem
> (besides more frequent downloading of emails)? Will an upgrade to 2.0a3
> help?
> 
> 
>          Stephen
> 
> 
>   ==== pop3server.log appended below ====  
> 
> 
> Tue Jul 09 15:35:47 EDT 2002 [INFO   ] (pop3server): POP3Server init...
> Tue Jul 09 15:35:47 EDT 2002 [INFO   ] (pop3server): POP3Listener using
> plain on port 110
> Tue Jul 09 15:35:47 EDT 2002 [INFO   ] (pop3server): POP3Server ...init end
> Tue Jul 09 15:43:06 EDT 2002 [INFO   ] (pop3server): Hello Name is: xxxxxxx
> Tue Jul 09 15:43:06 EDT 2002 [INFO   ] (pop3server): Connection from
> xxxxxxxx
> Tue Jul 09 15:43:06 EDT 2002 [INFO   ] (pop3server): Command received: AUTH
> Tue Jul 09 15:43:06 EDT 2002 [INFO   ] (pop3server): Command received: USER
> xxxxxxxx
> Tue Jul 09 15:43:06 EDT 2002 [INFO   ] (pop3server): Command received: PASS
> xxxxxxxx
> Tue Jul 09 15:43:16 EDT 2002 [INFO   ] (pop3server): Command received: STAT
> Tue Jul 09 15:43:40 EDT 2002 [ERROR  ] (pop3server): Exception during
> connection from xxxxxxxx : Exception caught while retrieving a stream :
> java.io.FileNotFoundException:
> D:\PF\Phoenix\apps\james\var\mail\inboxes\xxxx\4D61696C313032323739313534383137312D313937.Repository12.FileStreamStore
> (Too many open files)
> java.lang.RuntimeException: Exception caught while retrieving a stream :
> java.io.FileNotFoundException:
> D:\PF\Phoenix\apps\james\var\mail\inboxes\xxxx\4D61696C313032323739313534383137312D313937.Repository12.FileStreamStore
> (Too many open files)
> 	at
> org.apache.avalon.cornerstone.blocks.masterstore.File_Persistent_Stream_Repository.get(File_Persistent_Stream_Repository.java(Compiled
> Code))
> 	at
> org.apache.james.mailrepository.MimeMessageAvalonSource.getInputStream(MimeMessageAvalonSource.java(Compiled
> Code))
> 	at
> org.apache.james.core.MimeMessageSource.getMessageSize(MimeMessageSource.java(Compiled
> Code))
> 	at
> org.apache.james.core.MimeMessageWrapper.getMessageSize(MimeMessageWrapper.java(Compiled
> Code))
> 	at org.apache.james.core.MailImpl.getMessageSize(MailImpl.java(Compiled
> Code))
> 	at
> org.apache.james.pop3server.POP3Handler.doSTAT(POP3Handler.java(Compiled
> Code))
> 	at
> org.apache.james.pop3server.POP3Handler.parseCommand(POP3Handler.java:200)
> Tue Jul 09 15:45:16 EDT 2002 [ERROR  ] (pop3server): Connection timeout on
> socket
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Too Many Open Files

Posted by Stephen <ja...@spamgourmet.com>.
  Hello,

  Running James 2.0a2 on Windows 2000, using the filesystem as the 
repository. When there are lots of messages for a user (problem 
is seen somewhere between roughly 1000-2000 messages),  an error is
returned when the user tries to retrieve these messages via POP. 

  From the server logs, this error appears to have something to do with
"too many open files".

  When I last saw this, I stopped James and moved (the newest) 1/2 of the
files from the user's inbox folder to a temporary folder. Restarted James,
and was able to download the oldest messages. I then stopped James,
restored the files from the temporary folder back to the inbox, and was now
able to download these newest messages.

  Is this a known issue? Is there anything I can do to avoid the problem
(besides more frequent downloading of emails)? Will an upgrade to 2.0a3
help?


         Stephen


  ==== pop3server.log appended below ====  


Tue Jul 09 15:35:47 EDT 2002 [INFO   ] (pop3server): POP3Server init...
Tue Jul 09 15:35:47 EDT 2002 [INFO   ] (pop3server): POP3Listener using
plain on port 110
Tue Jul 09 15:35:47 EDT 2002 [INFO   ] (pop3server): POP3Server ...init end
Tue Jul 09 15:43:06 EDT 2002 [INFO   ] (pop3server): Hello Name is: xxxxxxx
Tue Jul 09 15:43:06 EDT 2002 [INFO   ] (pop3server): Connection from
xxxxxxxx
Tue Jul 09 15:43:06 EDT 2002 [INFO   ] (pop3server): Command received: AUTH
Tue Jul 09 15:43:06 EDT 2002 [INFO   ] (pop3server): Command received: USER
xxxxxxxx
Tue Jul 09 15:43:06 EDT 2002 [INFO   ] (pop3server): Command received: PASS
xxxxxxxx
Tue Jul 09 15:43:16 EDT 2002 [INFO   ] (pop3server): Command received: STAT
Tue Jul 09 15:43:40 EDT 2002 [ERROR  ] (pop3server): Exception during
connection from xxxxxxxx : Exception caught while retrieving a stream :
java.io.FileNotFoundException:
D:\PF\Phoenix\apps\james\var\mail\inboxes\xxxx\4D61696C313032323739313534383137312D313937.Repository12.FileStreamStore
(Too many open files)
java.lang.RuntimeException: Exception caught while retrieving a stream :
java.io.FileNotFoundException:
D:\PF\Phoenix\apps\james\var\mail\inboxes\xxxx\4D61696C313032323739313534383137312D313937.Repository12.FileStreamStore
(Too many open files)
	at
org.apache.avalon.cornerstone.blocks.masterstore.File_Persistent_Stream_Repository.get(File_Persistent_Stream_Repository.java(Compiled
Code))
	at
org.apache.james.mailrepository.MimeMessageAvalonSource.getInputStream(MimeMessageAvalonSource.java(Compiled
Code))
	at
org.apache.james.core.MimeMessageSource.getMessageSize(MimeMessageSource.java(Compiled
Code))
	at
org.apache.james.core.MimeMessageWrapper.getMessageSize(MimeMessageWrapper.java(Compiled
Code))
	at org.apache.james.core.MailImpl.getMessageSize(MailImpl.java(Compiled
Code))
	at
org.apache.james.pop3server.POP3Handler.doSTAT(POP3Handler.java(Compiled
Code))
	at
org.apache.james.pop3server.POP3Handler.parseCommand(POP3Handler.java:200)
Tue Jul 09 15:45:16 EDT 2002 [ERROR  ] (pop3server): Connection timeout on
socket

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>