开发者

Prevent url's from appearing as links in mail clients

I'm sending an HTML mail from my app, this mail contains URLs, is there a way to prevents from mail clients to show these URLs as links?

for example:

<table>
<tbody>
<tr>
<td>http://www.google.com</td>
</tr>
</tbody>
</table>

will generate" http://www.google.com

instead I want it to generate a 开发者_开发技巧static text.

any thoughts?


This is a feature of some mail clients and there's no foolproof way to stop them from doing whatever they want with the message contents.

You could try to trick the mail clients by wrapping the addresses in empty tags and hope that they aren't smart enough to see through it:

<td><span>http</span><span>://</span>www.<span>google.</span>com</td>


Use a "zero width space" character: &#8203;

It does as the name implies. It adds a space in your string but the space takes up zero width so instead of looking like two strings, it looks like one.


I have found the accepted answer doesn't work for Outlook 2013. I have had success with the following:

http<a href='#' style='text-decoration:none; color:#000;'>://www.google.</a>com

Setting the style cursor:default is not honored by Outlook 2013, but if you only make the middle of the url a hyperlink then a user can still select the link text without the cursor pointer appearing.


I'd say that largely depends on the mail client and thus is beyond your control. The only option would be to not make it a URL. E.g. write www.google.com (which the user can copy/paste just like the URL.


I didn't have any luck in preventing MacMail and Yahoo Mail from creating links out of any text string ending in .com (or other domain extension). After hours of testing (even 'href=""' and 'href="#"' did not work), I finally inserted my own URL and then manipulated the CSS and inline styles to remove the mail clients' link styling.


Adding in hidden line break elements in the right places seems to have fixed this for me (for now) in almost all clients, including desktop Outlook, according to Litmus's tests (Apple Mail desktop looks like the main exception).

https:<br style="display: none;"/>//www.w3<br style="display: none;"/>.org/TR/2020/WD-WCAG22-20200227/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜