hi i'm trying to read the end users mailbox by using spring mail integration. I have used following code it's working fine.
@SpringBootApplication
public class ImapTestApplication {
public static void main(String[] args) {
SpringApplication.run(ImapTestApplication.class, args);
ApplicationContext ac = new ClassPathXmlApplicationContext("/META-INF/gmail-imap-idle-config.xml");
DirectChannel inputChannel = ac.getBean("receiveChannel", DirectChannel.class);
inputChannel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) throws MessagingException {
System.out.println("===================================");
System.out.println("Message: " + message);
System.out.println("===================================");
}
});
}
And my xml configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
xmlns:util="http://www.springframework.org/schema/util">
<int:channel id="receiveChannel" />
<!-- replace 'userid and 'password' with the real values -->
<int-mail:imap-idle-channel-adapter id="customAdapter"
store-uri="imaps://mailaddress:password@host:993/inbox"
channel="receiveChannel"
auto-startup="true"
should-delete-messages="false"
should-mark-messages-as-read="false"
java-mail-properties="javaMailProperties"/>
<util:properties id="javaMailProperties">
<prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
<prop key="mail.imap.socketFactory.fallback">false</prop>
<prop key="mail.store.protocol">imaps</prop>
<prop key="mail.imaps.auth">true</prop>
<prop key="mail.debug">false</prop>
</util:properties>
</beans>
In my application i have more than 100 users mailbox information in my database. So how i need to configure from my database. And also in runtime if user change the mail setting like password change it should be perform my mail receiver as well, I try to implement using Spring Integration Java DSL but i cant use the imap settings from user mail database.