Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MailClient {
- private String host;
- private String username;
- private String password;
- private String provider;
- protected Session session;
- public MailClient() {
- Properties props = new Properties();
- this.host = "localhost";
- this.username = "unix-user";
- this.password = "unix-password";
- this.provider = "pop3";
- this.session = Session.getDefaultInstance(props, null);
- }
- public void checkInbox() throws MessagingException, IOException {
- Store store = session.getStore(provider);
- store.connect(host, username, password); //This is line 33
- Folder inbox = store.getFolder("inbox");
- inbox.open(Folder.READ_ONLY);
- Message[] messages = inbox.getMessages();
- for(Message message : messages){
- System.out.println(message.getReceivedDate());
- System.out.println(message.getSubject());
- }
- inbox.close(true);
- store.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement