PHP标题(位置:Mailto ..)上次更新后的Windows 7 Pro问题

时间:2016-09-15 20:16:54

标签: php windows mailto

自Windows 7上次更新以来,很多客户抱怨他们遇到以下错误:

损坏的内容错误

由于检测到数据传输错误,无法显示您要查看的页面。

当他们运行执行以下PHP(示例)脚本的PHP脚本时:

<?php
    header ('Location: mailto:xx@example.de?subject=hello&body=test' ); 
?>

有人知道这个问题的php解决方法吗?不幸的是,我不能让大量网络用户改变他们的系统。

来自德国的问候

3 个答案:

答案 0 :(得分:0)

当我尝试使用php Location标头重定向到mailto url时,我注意到了一些奇怪的东西。在我的情况下,当某些字符在主题中时,它会在IE(而不是Chrome)中失败(例如“Subject = RE:ABC”,冒号会导致IE进入barf。为了解决这个问题,我替换了PHP的位置重定向:

header ('Location: mailto:xx@example.de?subject=hello&body=test' );

使用javascritp等价物:

echo '<SCRIPT>window.location="mailto:xx@example.de?subject=hello&body=test";</SCRIPT>');

希望这有帮助!

答案 1 :(得分:0)

为避免在邮件处理程序完成后出现空白窗口(选项卡,页面),可以添加第二个header ("Location ...");重定向到您的主页,在这种情况下,请点击此处index.php

<?php
    header ("Location: mailto:xx@example.de", false);
    header ("Location: index.php");
    exit();
?>

答案 2 :(得分:0)

在测试期间,当我使用两个标头时,我发现mailto标头没有执行!参见https://stackoverflow.com/a/57862546/10655742。所以我找到了一个更好的解决方案。

在HTML文件中使用_self代替blank

<a href="mailto-handler.php" target="_self" rel="noopener noreferrer"></a>

Mailto-Handler.php

<?php
    header ("Location: mailto:xx@example.de");
    exit();
?>