How can receive emails in Java based system preferably with spring?
Asked Answered
K

2

6

I have looked up Google and Spring documentation but can not find any thing on receiving emails.

I need to build a client (kind of not fully blown client) that can receive emails from POP3 and IMAP. I am already using Spring in the project so preference is Spring.

Lots of links point to James but while it does look like a good project does not provide enough documentation and I am not even sure it does what I am after i.e just a small client that is able to to receive emails.

Kirst answered 2/2, 2012 at 9:0 Comment(0)
A
13

Spring integration was designed to solve these kind of problems. In particular it has e-mail receiving adapters. Here is an IMAP example from the documentation:

<mail:inbound-channel-adapter id="imapAdapter"
      store-uri="imaps://[username]:[password]@imap.gmail.com/INBOX"
      java-mail-properties="javaMailProperties"
      channel="recieveChannel"
      should-delete-messages="true"
      should-mark-messages-as-read="true"
      auto-startup="true">
      <int:poller max-messages-per-poll="1" fixed-rate="5000"/>
</mail:inbound-channel-adapter>
Acquittal answered 2/2, 2012 at 9:5 Comment(0)
O
2

POP3 and IMAP are not protocols that receive email. They go out and fetch it from a server.

The official JavaMail API

provides a platform-independent and protocol-independent framework to build mail and messaging applications.

Take a look!

Ostrander answered 2/2, 2012 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.