Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def props = new Properties()
- props.put 'mail.store.protocol', 'imaps'
- def host = 'imap.yandex.ru'
- def port = 993
- def username = 'username'
- def password = 'password'
- def store = Session.getDefaultInstance(props, null).store
- store.connect(host, port, username, password)
- def inbox = store.getFolder('Inbox')
- inbox.open(Folder.READ_ONLY)
- def messages = inbox.messages
- messages.each { Message message ->
- def from = message.getFrom().collect {javax.mail.Address address ->
- if (address instanceof InternetAddress)
- address.address
- else
- address.toString()
- }.join(';')
- def subject = message.subject
- println "$from\t$subject"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement