Results 1 to 3 of 3

Thread: Java Spring ImapIdleChannelAdapter and AUTHENTICATE PLAIN

Threaded View

  1. #1
    Join Date
    Aug 2011
    Posts
    10
    Rep Power
    4

    Default Java Spring ImapIdleChannelAdapter and AUTHENTICATE PLAIN

    Hi.

    I try to build an Java Spring App with ImapIdleChannelAdapter to receive all new incoming messages in multiple Mailboxes.

    I get single Usermailbox with the username/password for this mailbox to work and now i try to get access to this and the other mailboxes on the zimbra server with the admin username/password, cause i don't know the other username/password combines.

    My current code:
    Code:
    ImapIdleChannelAdapter channelAdapter = null;
    ImapMailReceiver mailReceiver = null;
    Properties props = null;
    try {
    	props = new Properties();
    	props.setProperty("mail.imap.host", "zimbra.server.tst");
    	props.setProperty("mail.imap.port", "993");
     	props.setProperty("mail.imap.auth.login.disable", "true");
    	props.setProperty("mail.imap.auth", "true");
    	props.setProperty("mail.imap.ssl.enable", "true");
    	props.setProperty("mail.store.protocol", "imaps");
    	props.setProperty("mail.debug", "true");
    	props.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    	props.setProperty("mail.imap.socketFactory.fallback", "false");
    	props.setProperty("mail.imap.connectionpoolsize", "5");
    
    	mailReceiver = new ImapMailReceiver("imaps://user1%40server.tst@zimbra.server.tst:993/INBOX");
    	mailReceiver.setJavaMailProperties(props);
    	mailReceiver.setJavaMailAuthenticator(new Authenticator() {
    		protected PasswordAuthentication getPasswordAuthentication() {
    			return new PasswordAuthentication("admin", "adminpassword");
    		}
    	});
    	mailReceiver.setShouldDeleteMessages(false);
    	mailReceiver.setShouldMarkMessagesAsRead(false);
    
    	ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    	taskScheduler.setPoolSize(5);
    	taskScheduler.afterPropertiesSet();
    
    	DirectChannel outputChannel = new DirectChannel();
    	outputChannel.subscribe(new MyMessageHandler());
    
    	channelAdapter = new ImapIdleChannelAdapter(mailReceiver);
    	channelAdapter.setShouldReconnectAutomatically(true);
    	channelAdapter.setTaskScheduler(taskScheduler);
    	channelAdapter.setOutputChannel(outputChannel);
    	channelAdapter.start();
    } catch (IllegalStateException ise) {
    	ise.printStackTrace();
    	if (channelAdapter != null) {
    		channelAdapter.stop();
    		try {
    			mailReceiver.destroy();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    }
    with this code i get the mailbox inbox from the admin, not from the user "user1"

    I would appreciate tips on

    greets rizzi
    Last edited by RizziCR; 09-16-2011 at 06:49 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •