Html 防止 url 在邮件客户端中显示为链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7625880/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:53:24  来源:igfitidea点击:

Prevent url's from appearing as links in mail clients

htmlemail

提问by Ran

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?

我正在从我的应用程序发送 HTML 邮件,该邮件包含 URL,有没有办法阻止邮件客户端将这些 URL 显示为链接?

for example:

例如:

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

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

将生成“ http://www.google.com

instead I want it to generate a static text.

相反,我希望它生成一个静态文本。

any thoughts?

有什么想法吗?

采纳答案by JJJ

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>

回答by stacigh

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

使用“零宽度空间”字符: &#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.

顾名思义,它确实如此。它在您的字符串中添加了一个空格,但该空格占用的宽度为零,因此看起来不像两个字符串,而是一个。

回答by Richard Williams

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

我发现接受的答案不适用于 Outlook 2013。我在以下方面取得了成功:

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

Setting the style cursor:defaultis 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.

cursor:defaultOutlook 2013 不支持设置样式,但如果您只将 url 的中间设置为超链接,那么用户仍然可以选择链接文本而不会出现光标指针。

回答by Deborah

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.

我没有成功阻止 MacMail 和 Yahoo Mail 从以 .com(或其他域扩展名)结尾的任何文本字符串中创建链接。经过数小时的测试(即使 'href=""' 和 'href="#"' 也不起作用),我终于插入了自己的 URL,然后操纵 CSS 和内联样式以删除邮件客户端的链接样式。

回答by Jan Algermissen

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.

我会说这在很大程度上取决于邮件客户端,因此超出了您的控制范围。唯一的选择是不使其成为 URL。例如写 www.google.com(用户可以像 URL 一样复制/粘贴。