【发布时间】:2012-10-06 02:12:22
【问题描述】:
我无法让这段代码工作我知道如何使用 PHP 的邮件部分,但无法理解有什么问题。
##Send activation Email
$to = $_POST['email'];
$subject = " YOURWEBSITE.com Registration";
$message = "Welcome to our website!\r\rYou, or someone using your email address, has completed registration at YOURWEBSITE.com. You can complete registration by clicking the following link:\rhttp://www.YOURWEBSITE.com/verify.php?$activationKey\r\rIf this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ YOURWEBSITE.com Team";
$headers = 'From: noreply@close2.me';
mail($to, $subject, $message, $headers);
【问题讨论】:
-
错误是什么?或者,什么不起作用?
-
@janenz00 它不会发送电子邮件。
-
mail() 函数很难调试(只返回真或假),是否可能是服务器设置问题?在 Linux 上,通常您可以在 /var/log/messages 处查看日志
-
无法在本地主机上发送,您需要在线托管才能工作。如果要发送,则需要安装一些东西才能正常工作....
-
不要使用 mail()。是没用的垃圾。使用适当的邮件包,如 PHPMailer 或 Swiftmailer,如果 PHP 级别出现故障,至少可以为您提供有用的诊断。
标签: php email activation