我认为代码中存在错误,我不知道它是什么,但Web服务器上的mail()肯定有效。
Html Mail包含
$to = $register_data['email'];
$subject = 'Activate Your Account';
$headers = "non-reply@bruhkunt.herobo.com\r\n";
$headers .= "CC: bruhkunt.herobo.com\r\n";
$headers .= "MIME-Version: 1.0 \r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$body = '<html><body>';
$body .= "<h1>Hello, " . $register_data['first_name'] . "</h1>\r\n";
$body .= "<p>To activate your account click the link below:</p>\r\n";
$body .= "<a href=\"http://bruhkunt.herobo.com/activate.php?email=" . $register_data['email'] . "&email_code=" .$register_data['email_code']."\"></a>\r\n";
$body .= "<p>If it does not work, copy and paste the link below:</p>\r\n";
$body .= "http://bruhkunt.herobo.com/activate.php?email=" . $register_data['email'] . "&email_code=" .$register_data['email_code']."\r\n";
$body .= '</body></html>';
邮件功能:
function email($to, $subject, $body, $headers) {
mail($to, $subject, $body, $headers);
}
这是发送主要内容:
function register_user($register_data) {
array_walk($register_data, 'array_sanitize');
$register_data['password'] = crypt($register_data['password'], 'st');
$field = '`' . implode('`, `', array_keys($register_data)) . '`';
$data = '\'' . implode('\', \'', $register_data) . '\'';
mysql_query("INSERT INTO `users` ($field) VALUES ($data)");
email(include('core/activation_mail.php'));
}
答案 0 :(得分:3)
您的函数email()
包含您指定的字段..
function email($to, $subject, $body, $headers)
^ ^ ^ ^
如果您不提供它们(在您的示例中没有提供它们),它将无法正确运行并引发错误。你想做这样的事情:
$body = file_get_contents(getcwd(). 'core/activation_mail.php');
email('tosomeone@somewhere.com', 'The Subject', $body, $headers);
我刚刚注意到您的“HTML电子邮件”页面,您不应该这样做,因为您现在必须尝试使用global
。如果你这样做可能会有效:
include('core/activation_mail.php');
email($to, $subject, $body, $headers);
请为了帮助自己,请正确阅读php。你正在做的事情是多余的,而不是最有效的方式。
正如@Fred所提到的,请务必阅读并了解PHP错误!使用此代码在脚本顶部打开错误报告!
ini_set('display_errors', 1);
error_reporting(E_ALL);