Resolve User Name from Email Address

0

1

I have noticed than in many popular email services such as GMail and Exchange, the email address of the user also contains the name of the sender.

For example jsmith@company.com will show up as John Smith <jsmith@company.com>.

Is there a way to determine the user name associated with an account by querying the server for that information? (in this case MS Exchange).

I want to create a script that automatically extracts the first and last name from their address to do personalize outgoing emails.

Brandon Kreisel

Posted 2013-05-28T20:41:16.293

Reputation: 973

Please clarify your question. Do you only have mails in the form username@example.com and want to (magically) get their full name, even if it's not supplied through the mail? Or does the mail's sender actually appear as John Doe <username@example.com? In what form do you have the mails (or access to them, respectively)? What's your operating system? – slhck – 2013-05-28T21:04:46.857

@slhck: The only available data is the email address itself. The intended service is MS Exchange which should supply a full name every time. Access would be within the same domain. Unix Platform – Brandon Kreisel – 2013-05-28T21:10:15.300

I don't think this is doable at all. If you had the full mail, including its header where the From: field designates the e-mail address and the sender's full name, that'd be no problem to extract, but just with the e-mail address alone… – slhck – 2013-05-28T21:14:33.263

your probably right, I was just holding out hope that there was some way of querying an Exchange or IMAP server for this information – Brandon Kreisel – 2013-05-28T21:16:48.010

That, I don't know. With Gmail it won't be possible, but you might have a change with an Exchange server you can query. But that's out of my knowledge, sorry :) – slhck – 2013-05-28T21:18:27.717

If you have a full exchange / active directory deployment (such as inside a company), and you know the emails are internal <username>@domain, then you can perform an LDAP query against the domain controller to pull first and last name based on username. This will not work for users outside of the domain, though. – Darth Android – 2013-05-28T21:33:17.640

I agree that it’s almost certainly impossible.  It might have been possible 20 years ago, but, as spam and phishing have increased, there has been a trend for mail servers/services to give out less and less information on their subscribers; e.g., not even confirming whether an email address is valid/active. – Scott – 2013-05-28T21:40:21.590

Normally your email client will notice the "friendly name" in incoming emails and store these for later use. As a general rule, you can't iterate through directories, for both SPAM and security (keep logins private when you can) reasons. – Rich Homolka – 2013-05-28T21:42:55.563

@DarthAndroid, in this case yes it would be internal with a full LDAP and AD deployment. This would be for internal use. – Brandon Kreisel – 2013-05-29T13:14:37.100

@BrandonKreisel This answer should get you headed in the right direction, though work would be required to get it into a runnable script. Perhaps reword your question to "Given an internal email address, how can I query Active Directory for that user's full name and print it out on the command line?"

– Darth Android – 2013-05-29T14:46:02.730

No answers