Files
spring-integration-samples/basic/mail
kasoban 68976a81a6 Add specific slf4j-api version dependency
When just importing the ftp example as a maven project, I ran into the issue of a slf4j version discrepancy described here:
http://www.slf4j.org/faq.html#IllegalAccessError

This is solved by adding the specific version dependency of `slf4j-api`.

* Add the specific `slf4j-api` dependency to the Gradle script
* Change the dependency scope for `slf4j-` impl to the `runtime`.
* Regenerate POMs
2016-01-04 09:54:04 -05:00
..
2014-04-16 20:45:34 +03: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...)