Preventing hyperlinked phone numbers in emails

Today, most email clients have some "intelligent" content detection where it will recoginse a link or phone number and convert it to a hyperlink, ready for the user to click on. For one of our clients, this was not great for two reasons:

  • The link colour was the default blue, which did not match the colour scheme of the email
  • They didn't want desktop users clicking on a phone number (which would do nothing in most cases)

Dispite our protests that we cannot control how email clients manipulate emails, they continued to fuss over it.

After a little digging around, the solution was fairly obvious. All we need to do "trick" the rendering engine, change the phone number to something it would not recognise as a phone number. Initially I tried to replace the digits with their HTML code:

+61 2 9999 8888 becomes +61 2 9999 8888

Gmail actually sees right through this and still applies a hyperlink. It was clear at this point that it was a guessing game as to what email clients would recognise what formats. So after more digging around, I found a suggestion to use the invisible HTML coded characters. The most popular being the Soft Hyphen and the Zero-width space.

+61 2 9999 8888 becomes +61­2­9999­8888

+61 2 9999 8888 becomes +61​ 2​ 9999​ 8888

While this worked for some email clients, Gmail proved smart enough to see through this. The final thing to try was to break up the phone number with extra HTML tags.

+61 2 9999 8888 becomes +61 <span>2</span>9999 8888

Eureka! This worked in the few email clients that we targeted, namely Gmail and Outlook. OWA stripped out the extra span tags but did not render the number as a link.