Stop mail clients auto-linking text as URLs

Wow – it’s been a while since I last posted…

This is just a quickie – a reminder for my own reference, but could also be useful to others.

I’m building a shop, and the email confirmations include the line:

Your credit card statement will show a payment to "MYDOMAIN.COM".

Which is fine, except that many mail clients (e.g. Apple Mail) will take MYDOMAIN.COM and link it as a URL – which I don’t want.

To avoid this, simply add a zero width space into the “URL” – for instance:

Your credit card statement will show a payment to "MYDOMAIN​.COM".

(That’s the HTML version. If you’re generating a plain text alternative (using CFML, of course), you’ll want to use #Chr(8203)#).

The text will now look identical – except it will not be linked by the mail client.

 

Comments

Adam Tuttle

Great tip! Bookmarking this because I know I'll need it sooner or later...

09 February 2010, 15:54
Reply
Sami Hoda

Good stuff!

12 February 2010, 05:44
Reply
Pro Backup - Online Backup

Thanks for sharing this hint, which could be used in PHP by declaring that character with:

html_entity_decode('?', ENT_NOQUOTES, 'UTF-8')

Other methods failed in PHP version 5.3.3 on Mac OS X 10.6.6:

- dec_to_utf8(8203)

- unicode_chr(8203)

16 January 2011, 22:02
Reply
Pro Backup - Online Backup

In Outlook 2003 on Windows 2003 (32-bit) the ​ (8203) 'zero width space' displays as an ugly square box instead of not being displayed at all.

22 January 2011, 17:18
Reply
Post a Comment
  1. Leave this field empty

Required Field