Search code examples
springspring-bootspring-integrationimap

Inappropriate behaviour of ImapMailReceiver


If the password contains @, ImapMailReceiver failed to return host correctly.

for example:

username: [email protected]

password: abc@123

host: imap.gmail.com

Final URI string

imap://[email protected]:abc@[email protected]:993/INBOX

then, ImapMailReceiver identify host as [email protected]

I checked this thread but I use JavaConfig way to create ImapMailReceiver where as the thread is about XML config way.

Any way to walk around of this issue?

Thanks!

UPDATE

Final URI string with encoding

imap://abc%40gmail.com:abc%[email protected]:993/INBOX

in this case, I got AuthenticationException.

May be above information help you to understand the problem.

UPDATE 1

above was an issue from Gmail. One need to enable LESS SECURE APP security option in Gmail to fix Authentication related issue.


Solution

  • RFC 1738 says:

    Within the user and password field, any ":", "@", or "/" must be encoded.
    

    I expect you already know how URL encoding works. If you want a refresher, page 18 of the same document is a good place to start.