Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guess name from email

Tags:

ruby

Is there a standard or simple way to guess a name from an email address, similar to what gmail does?

For example, "[email protected]" should give "John Smith".

Doing this shouldn't be too hard (strip domain name, remove special characters, capitalize, etc), but I'm sure there should be existing code for this.

Code in Ruby would be preferred, but any other language would be fine.

like image 366
Ralf Avatar asked Nov 29 '09 18:11

Ralf


People also ask

Can you track someone with their email?

Email tracking is already used by individuals, email marketers, spammers and phishers to understand where people are, validate email addresses, verify that emails are actually read by recipients, find out if they were forwarded and discover if a given email has made it past spam filters.

How do you automate names in an email?

To insert the auto-detected first name, use the syntax {auto-first}. Again, you can use this syntax in the Subject and Message. In the example below, we auto-detect the first name and use a fallback value of “old friend” in cases where the first name cannot be detected.

How do I automate a name in Gmail?

In Gmail, draft your email message. Give it a title. To add personalization to the email, add the column title you wish to use in curly brackets, e.g.{{First Name}} directly in the subject line and/or in the email body. This will allow you to automatically add first name in your bulk emails, see example below.


3 Answers

def email_to_name(email)
  name = email[/[^@]+/]
  name.split(".").map {|n| n.capitalize }.join(" ")
end

p email_to_name("[email protected]")
# => "John Smith"

This is such a simple task that I doubt you'll find any "existing code" doing this.

like image 184
August Lilleaas Avatar answered Nov 11 '22 19:11

August Lilleaas


The regex below should solve your problem

/(\w+)[._-](\w+)@.+/
like image 24
Piotr Czapla Avatar answered Nov 11 '22 17:11

Piotr Czapla


Gmail uses the envelope style email address one of the extensions to rfc-822. So it only guesses if the email address is in envolope form like this: Terry Terribad <[email protected]>.

For gmail it's then just a case of trying to figure out what goes in the front of the <> through parsing the email and generally guessing.

Otherwise there really is no way to guess that my name would be Chuck Vose from my email address as I don't use chuck.vose or anything like that.

like image 41
Chuck Vose Avatar answered Nov 11 '22 17:11

Chuck Vose