我是新来的PHP,请耐心等待。我创建了一个我正在创建的测试网站的注册。该网站收集用户信息,然后发送确认电子邮件。到目前为止,多次尝试后都没有收到邮件。我已经尝试过垃圾邮件文件夹,但无济于事。初学者PHP:Mail()函数不工作
这里是我的代码:
$to = "$email";
// Change this to your site admin email
$from = "[email protected]";
$subject = "Complete your registration";
//Begin HTML Email Message where you need to change the activation URL inside
$message = '<html>
<body bgcolor="#FFFFFF">
Hi ' . $username . ',
<br /><br />
You must complete this step to activate your account with us.
<br /><br />
Please click here to activate now >>
<a href="http://testw.freevar.com/activation.php?id=' . $id . '">
ACTIVATE NOW</a>
<br /><br />
Your Login Data is as follows:
<br /><br />
E-mail Address: ' . $email . ' <br />
Password: ' . $password . '
<br /><br />
Thanks!
</body>
</html>';
// end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "$to";
// Finally send the activation email to the member
mail($to, $subject, $message, $headers,-f $from);
提前感谢!
P.S.我已经在线阅读了一个php.ini文件夹。我从头创建一个网站,不知道这是什么或如果它是必要的。另外,我正在使用没有电子邮件地址的免费托管服务。我不确定这是否会影响它。
您是否可以访问任何可能会告诉您哪里出错的错误日志? – Chiubaka
您是否正在使用在Windows上运行的服务器进行测试?另外,'mail()'的最后一个参数前的'-f'是什么?你不能在那里。无论如何,您已经在'$ headers'中拥有发件人地址。 –
localhost?共享主机? VPS? – 2012-08-22 00:26:56