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.
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.
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.
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.
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.
The regex below should solve your problem
/(\w+)[._-](\w+)@.+/
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With