|
Ошибка Fatal error: Cannot redeclare
#38332994
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
Ссылка на профиль пользователя:
|
|
|
|
Добрый день!
Помогите с такой ошибкой у меня есть функция которая отправляет письмо.
При повторной вызовы этой функции выдает следующий ошибку:
Fatal error: Cannot redeclare get_data() (previously declared in Z:\home\localhost\www\\smtp.php:6) in Z:\home\localhost\www\humo\smtp.php on line 6
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87.
<?php
function send_mail($a,$b)
{
$mailto = $a;
$text=$b;
function get_data($smtp_conn)
{
$data="";
while($str = fgets($smtp_conn,515))
{
$data .= $str;
if(substr($str,3,1) == " ") { break; }
}
return $data;
}
$header="Date: ".date("D, j M Y G:i:s")." +0700\r\n";
$header.="From: =?windows-1251?Q?".str_replace("+","_",str_replace("%","=",urlencode('ТЕСТ')))."?= <test@test.com>\r\n";
$header.="X-Mailer: The Bat! (v3.99.3) Professional\r\n";
$header.="Reply-To: =?windows-1251?Q?".str_replace("+","_",str_replace("%","=",urlencode('ТЕСТ')))."?= <test@test.com>\r\n";
$header.="X-Priority: 3 (Normal)\r\n";
$header.="Message-ID: <172562218.".date("YmjHis")."@mail.ru>\r\n";
$header.="To: =?windows-1251?Q?".str_replace("+","_",str_replace("%","=",urlencode('')))."?= <$mailto>\r\n";
$header.="Subject: =?windows-1251?Q?".str_replace("+","_",str_replace("%","=",urlencode('проверка')))."?=\r\n";
$header.="MIME-Version: 1.0\r\n";
$header.="Content-Type: text/plain; charset=windows-1251\r\n";
$header.="Content-Transfer-Encoding: 8bit\r\n";
#$text="привет, проверка связи.";
$smtp_conn = fsockopen("192.168.0.2", 25,$errno, $errstr, 10);
if(!$smtp_conn) {print "соединение с серверов не прошло"; fclose($smtp_conn); exit;}
$data = get_data($smtp_conn);
fputs($smtp_conn,"EHLO vasya\r\n");
$code = substr(get_data($smtp_conn),0,3);
if($code != 250) {print "ошибка приветсвия EHLO"; fclose($smtp_conn); exit;}
fputs($smtp_conn,"AUTH LOGIN\r\n");
$code = substr(get_data($smtp_conn),0,3);
if($code != 334) {print "сервер не разрешил начать авторизацию"; fclose($smtp_conn); exit;}
fputs($smtp_conn,base64_encode("test@test.com")."\r\n");
$code = substr(get_data($smtp_conn),0,3);
if($code != 334) {print "ошибка доступа к такому юзеру"; fclose($smtp_conn); exit;}
fputs($smtp_conn,base64_encode("12345")."\r\n");
$code = substr(get_data($smtp_conn),0,3);
if($code != 235) {print "не правильный пароль"; fclose($smtp_conn); exit;}
$size_msg=strlen($header."\r\n".$text);
fputs($smtp_conn,"MAIL FROM:<kurs@humo.tj> SIZE=".$size_msg."\r\n");
$code = substr(get_data($smtp_conn),0,3);
if($code != 250) {print "сервер отказал в команде MAIL FROM"; fclose($smtp_conn); exit;}
fputs($smtp_conn,"RCPT TO:<$mailto>\r\n");
$code = substr(get_data($smtp_conn),0,3);
if($code != 250 AND $code != 251) {print "Сервер не принял команду RCPT TO"; fclose($smtp_conn); exit;}
fputs($smtp_conn,"DATA\r\n");
$code = substr(get_data($smtp_conn),0,3);
if($code != 354) {print "сервер не принял DATA"; fclose($smtp_conn); exit;}
fputs($smtp_conn,$header."\r\n".$text."\r\n.\r\n");
$code = substr(get_data($smtp_conn),0,3);
if($code != 250) {print "ошибка отправки письма"; fclose($smtp_conn); exit;}
fputs($smtp_conn,"QUIT\r\n");
fclose($smtp_conn);
}
$sot_arr[]="test1@test.com";
$sot_arr[]="test2@test.com";
$sot_arr[]="test3@test.com";
$sot_arr[]="test4@test.com";
$sot_arr[]="test5@test.com";
$count = count($sot_arr);
while (($count)!=0)
{
$count--;
echo $sot_arr[$count]."<br>";
send_mail($sot_arr[$count],"Проверочное письмо для проверки!");
}
?>
При таком раскладе первый адресат получает письмо test5@test.com, при повторной вызове дает ошибку.
В чем может быть проблема?
|
|
|