Outlook从电子邮件中删除URL哈希 [英] Outlook strips URL hash from email
问题描述
我们的应用程式会产生包含与散列片段的连结的电子邮件。
Our app generates an email that includes a link with a hash fragment.
- 当Outlook 2010用户点击HTML链接(
< a>
标签),URL被打开,但神秘地排除哈希片段。 - 如果用户单击纯文本URL(Outlook转换为可点击链接)完整的网址正确打开。
- When an Outlook 2010 user clicks the HTML link (within the
<a>
tag), the URL is opened but mysteriously excludes the hash fragment. - If the user clicks the plain URL (that Outlook converts to a clickable link), the full URL opens correctly.
这是Rails应用程序的相关代码,如果这有帮助:
Here is the relevant code from our Rails app, if that helps:
mail(from: @message.from, to: @message.to, cc: @message.cc, bcc: @message.bcc, subject: @message.subject) do |format|
format.html { render text: @message.body_text }
end
电子邮件消息(截断;使用Twitter网址代替我们的应用程序网址,遵循类似的模式):
Email message (truncated; using Twitter URLs in place of our app URLs, which follow a similar pattern):
Subject: Hello
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<html>
<head>
<meta content='text/html; charset=utf-8' http-equiv='content-type'>
<title>title</title>
</head>
<body>
<table id='message_body_template'>
<tr>
<td>
<p><a href="http://twitter.com/#!/cnn" title="" target="">Click here</a>
to learn more.</p>
<p>Plain text link: http://twitter.com/#!/cnn</p>
</td>
</tr>
</table>
</body>
</html>
点击这里打开Twitter主页,而纯文本链接打开CNN的Twitter页面。任何人都可以解释为什么?
Click here opens the Twitter home page, while the plain text "link" opens CNN's Twitter page. Can anyone explain why?
推荐答案
是的,问题与您使用的后端无关。看来(令人沮丧的是)某些版本的Outlook会将URL的哈希部分删除。
Yes, the problem is unrelated to what back-end you use. It appears that (frustratingly) some versions of Outlook strip the hash portion of URLs.
我的解决方案是将的修改版本的邮件发送给哈希,然后重定向到它应该去的地方。
My solution was to email a modified version of the link without the hash, and then redirect it to where it's supposed to go.
当我在Laravel + Backbone中遇到同样的问题时,我执行了在Rails中的 routes.php
(相当于 routes.rb
)中使用此代码进行重定向:
When I had the same issue in Laravel + Backbone I performed the redirect using this code in routes.php
(equivalent to routes.rb
in Rails):
// Redirect /password-reset/XYZ to #/password-reset/XYZ
Route::get('/password-reset/{any}', function() {
$url = Request::url(); // Get full URL
$path = Request::path(); // Get portion of URL after the domain name
return Redirect::to(str_replace($path, "#", $url) . $path);
});
这篇关于Outlook从电子邮件中删除URL哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!