Добавляем в зависимости Мавена
<!-- http://repo1.maven.org/maven2/javax/mail/javax.mail-api/1.5.6/javax.mail-api-1.5.6.jar --> <dependency> <groupId>javax.mail</groupId> <artifactId>javax.mail-api</artifactId> <version>1.6.2</version> </dependency> <!-- http://repo1.maven.org/maven2/javax/mail/mail/1.4.7/mail-1.4.7.jar --> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.7</version> </dependency>
- Setup properties for the mail session.
- Creates a
javax.mail.Authenticator
object. - Creating mail session.
- Get the POP3 store provider and connect to the store.
- Get folder and open the INBOX folder in the store.
- Retrieve the messages from the folder.
- Close folder and close store.
Выглядит все просто, но из коробки не завелось. Вылезла странная проблема с кодировкой Subject-a писем.