我发送用户注册的激活码,但Mail()和Pear Mail实际上都是访问发送时放置在正文中的链接。我以前从未见过这个,我假设已经启用了PHP设置,需要禁用它。
下面是一个示例,如果您访问test.php它会发送一封电子邮件,但PHP也会阅读正文中的链接并访问testme.php。该文件然后也发送电子邮件给我。我只收到2封电子邮件,只访问test.php。现在无法创建激活链接,因为我在收到电子邮件之前一直处于激活状态。
这让我花了6个小时才意识到发生了什么,我已经厌倦了。
代码作为基本测试:
test.php的:
<?php
$to = 'xxxxxxx';
$subject = "From Test.php";
$body = "Thank you for registering.\n\n To activate your account, please click on this link:\n\n http://xxxxx.com/testme.php\n\n Thanks\n";
$additionalheaders = "From: <XXXXXXX>\r\n";
$additionalheaders .= "Reply-To: XXXXXXX";
mail($to, $subject, $body, $additionalheaders);
echo "done";
?>
testme.php:
<?php
$to = 'xxxxxxx';
$subject = "From Test Me";
$body = "You shouldn't receive this";
$additionalheaders = "From: <xxxxxxx>\r\n";
$additionalheaders .= "Reply-To: xxxxxxx";
mail($to, $subject, $body, $additionalheaders);
?>
任何想法会导致什么?服务器正在运行PHP版本5.4.45