После того, как пользователь зарегистрируется, я хочу, чтобы они получили электронное письмо с моего локального хост-сервера, который я запускаю. Тот же сценарий ниже отлично работает на платном хостинге, но когда я пытаюсь запустить его на локальном хосте, я получаю следующую ошибку:
ПРИМЕЧАНИЕ. Неопределенная переменная: Заголовки в /Applications/XAMPP/xamppfiles/htdocs/site/newuser.php в строке 60
else {
echo "<br /><center>** CHECK SPAM **. We have sent a activation code to your email,
you will not be able to login follow the steps.</center>";
$name = $_POST['name'];
$password = sha1(md5($_POST['password']));
$email = $_POST['email'];
$cwid = $_POST['cwid'];
$verificationCode = md5(uniqid($_POST['name'], true));
(LINE 60) $headers .= "Reply-To: Kwame Project<[email protected]>\r\n";
$headers .= "Return-Path: Kwame Project<[email protected]>\r\n";
$headers .= "From: Kwame Project<[email protected]>\r\n";
$headers .= "Organization: Kwame\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
$message = "Hello " . $name . "! It appears you have registed an
account with us.\r\nIn order to complete your registration, you must
click the link below.\r\n" . $siteURL . "activate.php?
code=".$verificationCode."\r\nThank you!";
$message = wordwrap($message, 70, "\r\n");
mail($email, 'Activate Your Account', $message, $headers);
$InsertUser = $database->prepare("INSERT INTO students ('cwid', 'name',
'password', 'activated', 'activation_code', 'email', 'user_group')
VALUES (?, ?, ?, ?, ?, ?, ?)");
$InsertUser->execute(array($cwid, $name, $password, 0,
$verificationCode, $email, 0));
header('Refresh: 3; url=login.php');
}
}
Что-то вроде этого:
...........
$headers = '';
(LINE 60) $headers .= "Reply-To: Kwame Project<[email protected]>\r\n";
$headers .= "Return-Path: Kwame Project<[email protected]>\r\n";
$headers .= "From: Kwame Project<[email protected]>\r\n";
$headers .= "Organization: Kwame\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
$message = "Hello " . $name . "! It appears you have registed an
account with us.\r\nIn order to complete your registration, you must
click the link below.\r\n" . $siteURL . "activate.php?
code=".$verificationCode."\r\nThank you!";
$message = wordwrap($message, 70, "\r\n");
mail($email, 'Activate Your Account', $message, $headers);
$InsertUser = $database->prepare("INSERT INTO students ('cwid', 'name',
'password', 'activated', 'activation_code', 'email', 'user_group')
VALUES (?, ?, ?, ?, ?, ?, ?)");
$InsertUser->execute(array($cwid, $name, $password, 0,
$verificationCode, $email, 0));
header('Refresh: 3; url=login.php');
Попробуйте инициализировать переменную $ headers перед строкой 60:
$headers = '';
$headers .= ...
на$headers = ...
?