Search code examples
javaandroidemailsmtpimap

Do SMTP/IMAP servers save the email address for an existing email account? Can it be retrieved?


Do the mail servers keep the address for an existing account? Can the address be queried?

For example, if I have an existing account and its user name (login name) and password, but I forgot/lost the domain name. Is it possible to retrieve the complete mail address from mail servers (whether INCOMING or OUTGOING)? If it's possible, are there any APIs or classes to implement it on android apps?

I know some mail services consider the complete mail address as its login name, and they ask for the fully address to login. I am not talking about this case.

Will the mail servers provide the address for my account? I would be grateful if someone explain for these questions.


Solution

  • Mail servers generally log the address in the message in the message itself and you can look at that.

    Issue foo uid fetch x:y body.peek[header.fields (received)] for a set of messages. The first Received field for each message frequently contains a "for" clause. Here's one from my inbox (abbreviated for clarity):

    Received: from ... by ... with lmtp id ... for [email protected]; Sun, 22 Jun 2014 20:52:26 +0000
    

    The address in the "for" clause is generally an address belonging to the IMAP account, if it is present at all. The for clause is optional, so you can't rely on it.

    Note that for clauses in the second and subsequent Received fields are much less reliable.