cwius
cwius

Reputation:

Stop Auto-hyperlink in Outlook, Gmail etc

My web application sends emails to users. The email contains a link for further user action. Our security standards require that the link in the email cannot be clickable. However, the email clients recognize https:// in the email and auto-link the URL.

Any idea on how to stop the email clients to auto-link. I am thinking if I skip the https://, it may stop the auto-linking. But, if I have to keep the https:// is there any way to avoid auto-linking.

The link in the email is dynamically constructed in the c# code.

Upvotes: 13

Views: 12965

Answers (9)

Shane
Shane

Reputation: 313

This is what i did:

  • Replace all instances of "." with <span style=""color:transparent; font-size:0px;"">[{</span>.<span style=""color:transparent; font-size:0px;"">}]</span>
  • Replace all instances of "@" with <span style=""color:transparent; font-size:0px;"">[{</span>@<span style=""color:transparent; font-size:0px;"">}]</span>

These characters stopped it parsing links and email addresses, but aren't visible to the user. The negative is that when you copy and paste an email for example, you end up with: "test1{[{.}]}domain{[{.}]}com"

.

Upvotes: 0

Amir
Amir

Reputation: 701

@raugfer suggests in another answer: wrap the email/URL with an anchor.

<a name="myname">[email protected]</a>

Quoting from that answer:

Since the text is already wrapped in a hyperlink, Gmail gives up and leave it alone. :)

(Note: also worked for Apple mail client.)

Upvotes: 4

Lars Gyrup Brink Nielsen
Lars Gyrup Brink Nielsen

Reputation: 4105

Just create a plain <span> tag around the colon (<span>:</span>) or something like that :)

Upvotes: 5

dmayo
dmayo

Reputation: 640

I too wish to disable this, as I believe this is a "valid" use as to not wanting auto-linking (one reason is the designer wants it that way, and they are currently paying the bills).

In email sent that has no images, the header has the domain name in it: EXTRANET.EXAMPLE.COM

I even put inline styles to make sure it stays white on a black background: <span style="font-size: 1.5em;padding: 0.5em 0;text-transform: uppercase; font-weight:bold;color:#FFFFFF;text-decoration:none;">EXTRANET.EXAMPLE.COM</span>

Gmail makes this a link, adds an underline and also turns it bright blue instead of the intended white.

At first I tried replacing the dots with &#46; which made it look fine, but didn't fool the Gmail parser.

So, I added a spanned space which work just fine (i.e. it fools Gmail's parser):

<span style="font-size: 1.5em;padding: 0.5em 0;text-transform: uppercase; font-weight:bold;color:#FFFFFF;text-decoration:none;">EXTRANET<span style="font-size:0.1em">&nbsp;</span>.<span style="font-size:0.1em">&nbsp;</span>EXAMPLE<span style="font-size:0.1em">&nbsp;</span>.<span style="font-size:0.1em">&nbsp;</span>COM</span>

Upvotes: 6

Kris
Kris

Reputation: 31

Sorry to dredge up an old question, but I just tried the answer suggested by pieman72, and found that it didn't work within Outlooks 2007–2013. However, wrapping the individual elements of the URL within table cells did fool the Outlook parser:

Visit <table><tr><td>www.</td><td>website</td><td>.com</td></tr></table> for more information.

I ran a sample message through the Email On Acid test suite and found that it eluded the parser on all the major e-mail clients which automatically convert URLs (Outlook, iOS, Android 2.2, etc.) I did not run any deliverability tests.

Upvotes: 3

pieman72
pieman72

Reputation: 864

I know this thread is old, but I just had this issue myself, and wasn't thrilled by the gif image fix. If you're working with HTML emails, a slightly nicer solution is to break up the link text with a non-rendering tag that tricks the parser. I'm a fan of a simple non-existant <z>:

  https<z>://securesite.</z>com

It even works in Stack Overflow posts: https://securesite.com.

Hope this helps someone.

Upvotes: 22

Sandwich
Sandwich

Reputation: 525

Necroing the question, I know, but it's relevant... I'd like to present a reasonable scenario where Gmail's auto-linking (at least - haven't tested other clients) doesn't make sense.

A client has an application form on their site, where visitors fill out some personal information and submit it. The system then sends a notification email to the client, presenting the information the visitor supplied.

I'm wanting to enhance the email sent to the client by adding a <textarea> at the bottom, with the fields the visitor filled out presented in CSV format so that the client can simply copy it all and paste it into a spreadsheet.

Gmail, however, fails to recognize that the URLs and email addresses are inside a <textarea> tag, and "helpfully" adds the <a href="...">...</a> link code around the URL/email - inside the <textarea>. This results in the raw HTML link code showing up in the <textarea>.

Upvotes: 1

vtse
vtse

Reputation: 21

My application has a similar security requirement. The solution we used was to add an underscore to the beginning of the URL (_http://).

Upvotes: 2

abelenky
abelenky

Reputation: 64710

Replace the actual text with a small GIF image that looks like text.

Email parsers will not recognize text within an image.

Upvotes: 2

Related Questions