Question

Is it possible to ask an IMAP server for the full email address (refered on mailcore2 as mailbox) of the user?

Some background on why I want to know:

I ask my user to enter their IMAP account details such as username, password, hostname and port. With that information I can successfully connect to the server.

On another part of my app, I need to know the email address associated with that IMAP account. On most servers, the username is the actual email address, but not always. For example, google accepts as username abc.def when the full email is abc.def@gmail.com.

You can say: Why the question? Just ask the user for their email as well. Well, I would like not to bloat my interface too much by asking the user to enter yet another string of text, so that is why I'm wondering if there's any way to do this behind the scenes... Thanks.

Was it helpful?

Solution

There was a proposed IMAP extension called POSTADDRESS to do what you want, but so few people added support that the extension died. You might as well ignore it at this point.

Most sensible clients seen to ask for address and password, and try some likely logins based on the email address. If a guess works, fine, if not it's time to ask the user.

OTHER TIPS

The usual way is the other way round -- you ask for the e-mail address, and let some heuristic determine other settings like the IMAP server.

There's some way to get the email address at authentication time. See https://developers.google.com/gmail/imap_extensions

The server will send something similar to:

a001 OK username@gmail.com authenticated (Success)

Feel free to add a feature request to mailcore2 to grab the email address. Though, the caveat is that it will easily break.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top