Files
spring-integration-samples/basic/mail
Artem Bilan 5f524dc534 Upgrade to SI-5.0 & SIK-3.0, Reactor 3.0
* Fix compatibility after Java DSL migration to the SI Core
* Also upgrade all the JMS sample to the JMS 2.0
* Fix default `connectionFactory` bean reference to the current `jmsConnectionFactory`
* Remove unsupported JPA-1.0 Spec via `OpenJpaAutoConfiguration`, since the minimum now is JPA-2.0
* Remove non-lambda sample since minimum now is Java 8
* Rename `PromiseTest` to `MonoTest` and fix it to Reactor 3.0
* Fix `stomp-server.xml` to use proper Reactor 3.0 `eactor.util.function.Tuples` for SpEL
* Regenerate POMs
2016-11-18 14:11:32 -05:00
..

Mail sample

This example demonstrates the following aspects of the Mail support available with Spring Integration:

  1. IMAP IDLE Inbound Channel Adapter (with sample GMail configuration)
  2. POP3 Inbound Channel Adapter (with sample GMail configuration)

Simply change configuration file (src/main/resources/META-INF/spring/integration/gmail-imap-idle-config.xml or gmail-pop3-config.xml) to point to your existing GMail account (replace userid and password) and run:

  • GmailInboundImapIdleAdapterTest.java - for IMAP IDLE sample
  • GmailInboundPop3AdapterTest - for POP3 sample

IMPORTANT: You must enable POP3/IMAP access for your google account (follow Settings link on your GMail page).

Once started, start sending emails to your account. You'll see that adapter will receive messages and will publish them to a channel specified by 'channel' attribute.

You should see the output similar to this:

DEBUG: org.springframework.integration.mail.ImapMailReceiver - connecting to store [imaps://<your_user_name>:*****@imap.gmail.com:993/inbox]
DEBUG: org.springframework.integration.mail.ImapMailReceiver - opening folder [imaps://<your_user_name>:*****@imap.gmail.com:993/inbox]
INFO : org.springframework.integration.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]

Send a Message and you will see:

DEBUG: org.springframework.integration.mail.ImapMailReceiver - found 2 new messages
DEBUG: org.springframework.integration.mail.ImapIdleChannelAdapter - received 2 mail messages
INFO : org.springframework.integration.samples.mail.imapidle.GmailImapIdleAdapterTest - Message: [Payload=javax.mail.internet.MimeMessage@1f00aff5][Headers={$timestamp=1284745370451, $id=9dfd4b30-2d15-4905-9301-f39aa4073ea0}]
INFO : org.springframework.integration.samples.mail.imapidle.GmailImapIdleAdapterTest - Message: [Payload=javax.mail.internet.MimeMessage@66200db9][Headers={$timestamp=1284745370452, $id=4b8322ba-f469-4afc-af4f-1332a94b735b}]
DEBUG: org.springframework.integration.mail.ImapIdleChannelAdapter - waiting for mail
DEBUG: org.springframework.integration.mail.ImapMailReceiver - opening folder [imaps://<your_user_name>:*****@imap.gmail.com:993/inbox]

You can experiment with various attributes of the adapter (e.g., should-delete-messages, should-mark-messages-as-read etc...)