Reputation: 21
I am using org.springframework.integration.mail.ImapMailReceiver from spring integration to read some emails from IMAP server.
Like many other IMAP servers, the IMAP server I am connecting to uses emails addresses as usernames.
So I am creating new instance of ImapMailReceiver this way
new ImapMailReceiver(“imap://[email protected]:[email protected]:143/INBOX”);
I believe ImapMailReceiver uses URLName class to parse the given string into protocol, user and etc.
However since the url string contains 2 '@' characters, URLName class is getting confused and failing to parse the username and password.
Have anybody else had similar problems before? How did you get around this problem?
Any comments will be appretiated!!
Thanks.
Upvotes: 2
Views: 1388
Reputation: 1828
I've try to get mails from GMAIL that's why I use imaps
`imapMailReceiver = new ImapMailReceiver("imaps://" + URLEncoder.encode(USERNAME, "UTF-8") + ":" + PASSWORD + "@imap.gmail.com:993/INBOX");`
No, it works well
Upvotes: 3
Reputation: 29971
The "@" in the user name needs to be URL encoded. If you use the URLName constructor that takes separate username, password, etc. parameters, it will do that for you. If you're writing it by hand, you need to write it correctly, with the proper encoding for any special characters.
Upvotes: 6