HTML 邮件我想我做错了什么
The HTML Mail i think i did something wrong
我认为代码中有错误,我不知道它是什么,但网络服务器上的 mail() 确实可以正常工作。
Html邮件包含
$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'));
}
您的函数 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 email" 页面,你不应该那样做,因为你现在必须尝试使用 global
。如果您这样做可能会奏效:
include('core/activation_mail.php');
email($to, $subject, $body, $headers);
为了帮助自己,请正确阅读 php。你这样做是多余的,不是最有效的方法。
正如@Fred 提到的,请始终阅读并了解您的 PHP 错误!使用脚本顶部的此代码打开错误报告!
ini_set('display_errors', 1);
error_reporting(E_ALL);
我认为代码中有错误,我不知道它是什么,但网络服务器上的 mail() 确实可以正常工作。
Html邮件包含
$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'));
}
您的函数 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 email" 页面,你不应该那样做,因为你现在必须尝试使用 global
。如果您这样做可能会奏效:
include('core/activation_mail.php');
email($to, $subject, $body, $headers);
为了帮助自己,请正确阅读 php。你这样做是多余的,不是最有效的方法。
正如@Fred 提到的,请始终阅读并了解您的 PHP 错误!使用脚本顶部的此代码打开错误报告!
ini_set('display_errors', 1);
error_reporting(E_ALL);