2015-12-10 5 views
1

После регистрации моего пользователя я хочу, чтобы они получили электронное письмо с моего локального хост-сервера, на котором я запущен. Же ниже сценарий отлично работает на платный хостинг, но когда я пытаюсь запустить его на моем локальном хосте я получаю следующее сообщение об ошибке:Неопределенный заголовок переменной в PHP SEND MAIL

NOTE: Undefined Variable: Headers in /Applications/XAMPP/xamppfiles/htdocs/site/newuser.php on line 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'); 
} 


} 
+1

Что происходит, когда вы меняете линии 60 от '$ заголовков = ...' 'до $ заголовков = ...'? –

+0

Не хватает кода? – chriz

+0

Нет, это все код, относящийся к той части инструкции if else. –

ответ

0

Try инициализировать переменную $ заголовки перед строкой 60:

$headers = ''; 
+0

Как? Пожалуйста, дайте мне пример –

0

Что-то вроде этого:.

........... 
$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'); 
Смежные вопросы