phpmailer перестал работать - PullRequest
0 голосов
/ 23 марта 2020

У меня перестал работать почтовик, и я не могу заставить его работать снова. Я скачал новейший phpmailer 5.5 с githhub и перекодировал страницу. Я использовал примеры для создания своей почтовой программы и создал свою форму, и когда я включил отчеты об ошибках, я не могу понять эту ошибку. Я посмотрел примеры на вашем сайте, и я не смог использовать
Неустранимая ошибка: класс 'PHPMailer' не найден
мой сервер использует PHP Версия 7.3.15 с Вирус роговицы это важно для меня, чтобы остаться на месте, ты можешь мне помочь ???




<!DOCTYPE html>
<html lang="en" class="no-js">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<head>
<meta charset="utf-8">
<title>test | semndinbg mail</title>
<link rel="stylesheet" href="css/repairstatus.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>



<form id="form_1130906" class="appnitro"  method="post" action="">

<div id="contact_slide1">							
				
<div id="contact_name">FULL NAME: *<br>
<input id="element_4" name="name" class="element text medium" type="text" maxlength="50" value="" placeholder="FULL NAME"/></div> 
		
        
<div id="contact_phone">PHONE NUMBER: *<br>
<input id="element_2_1" name="phone" class="element text" size="15" maxlength="15" value="" type="text" placeholder="PHONE NUMBER"></div> 	
			
</div> <!--contact_slide1-->
<div id="contact_slide2">

<div id="contact_email">VEHICLE MAKE: *<br>
<input id="element_1" name="email" class="element text medium" type="text" maxlength="40" value="" placeholder="Ex: FORD"/></div> 

<div id="contact_contact">VEHICLE MODEL: *<br>
<input id="element_1" name="email" class="element text medium" type="text" maxlength="40" value="" placeholder="Ex: TAURUS"/></div> 



</div> <!--contact_slide2-->


<div id="contact_message">MESSAGE:<br>
<textarea id="element_3" name="message" class="element textarea medium" placeholder="START TYPING MESAGE HERE..."></textarea></div> 

			    
                
                
<div id="contact_slide3">              
<input id="saveForm" class="button_text" type="submit" name="submit" value="SEND" />
</div><!--contact_slide3-->       
               


		</form>	





<?php




if (isset($_POST['submit'])){



//check if post form was submitted
if(isset($_POST)){
//check if hidden value was used
if(isset($_POST['miles']) && trim($_POST['miles']) !=''){
die('THERE WAS AN ERROR');
}
//implode all the post data and check against bad words in a text file
$my_bad_file = "inc/words.txt"; //make a new file and insert any bad items one per line, Phrases work as well
if(!file_exists($my_bad_file)){
die("Can't find $my_bad_file");
}
$check_content = implode(",", $_POST);
$bad_content_array = array_map('rtrim', file($my_bad_file));
foreach ($bad_content_array as $bad_content) {
$bad_content = strtolower($bad_content);
if (strpos(strtolower($check_content), $bad_content) !== false) {
die('THERE WAS A BAD ERROR');
}}

}

    echo "Mailer Error:" . $mail->ErrorInfo;
    ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);









 require("inc/PHPMailer2/src/PHPMailer.php");
  require("inc/PHPMailer2/src/SMTP.php");

    $mail = new PHPMailer/PHPMailer/PHPMailer();
    $mail->IsSMTP(); // enable SMTP









//Create a new PHPMailer instance

$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();

//Enable SMTP debugging
// SMTP::DEBUG_OFF = off (for production use)
// SMTP::DEBUG_CLIENT = client messages
// SMTP::DEBUG_SERVER = client and server messages
$mail->SMTPDebug = SMTP::DEBUG_SERVER;

//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6

//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;

//Set the encryption mechanism to use - STARTTLS or SMTPS
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;

//Whether to use SMTP authentication
$mail->SMTPAuth = true;


//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = 'test@gmail.com';

//Password to use for SMTP authentication
$mail->Password = 'aaaa1111';

//Set who the message is to be sent from
$mail->setFrom('from@example.com', 'First Last');

//Set an alternative reply-to address
$mail->addReplyTo('replyto@example.com', 'First Last');

//Set who the message is to be sent to
$mail->addAddress('whoto@example.com', 'John Doe');

//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';

//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), __DIR__);

//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';

//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');

$mail->AddAddress('test@test.com');




$mail->Priority = 1;
$mail->WordWrap = 50;   // set word wrap
$mail->IsHTML(true);   // send as HTML
$mail->Subject  =  "FINE LINE AUTO BODY | Repair Status";	
$mail->AltBody  =  "This is the text-only body";

$name = isset($_POST['name']) ? $_POST['name'] : '';
$phone = isset($_POST['phone']) ? $_POST['phone'] : '';
$make = isset($_POST['make']) ? $_POST['make'] : '';
$model = isset($_POST['model']) ? $_POST['model'] : '';
$message = isset($_POST['message']) ? $_POST['message'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$phone = isset($_POST['phone']) ? $_POST['phone'] : '';

// gets info from form
$name = $_POST['name'] ;
$phone = $_POST['phone'] ;
$make = $_POST['make'] ;
$model = $_POST['model'] ;

$message = $_POST['message'] ;





$ip = $_SERVER["REMOTE_HOST"] ?: gethostbyaddr($_SERVER["REMOTE_ADDR"]);


 // defines how message looks in email
$mail->Body="
<html>
<head>
</head>
<body>
<center>

<span style='color:red;'>This is from a customer, We are repairing his vehicle. Lets not keep them waiting!</span>
<div style='width:750px;text-align:center;'>
<div style='float:;'>
<span style='font-size:px;'><b>Personal Info</b><br></span>
<br>
<span style='font-size:px;'>---------------<br></span>
<br>
<span style='font-size:px;'>Full Name: $name<br></span>
<br>
<span style='font-size:px;'>Phone Number: $phone<br></span>
<br>
<span style='font-size:px;'>Vehicle Make: $make<br></span>
<br>
<span style='font-size:px;'>Vehicle Model: $model<br></span>
<br>
<span style='font-size:px;'>Message: $message<br></span>

</div></div>
</center>
</body>
</html> 


";




// looks good in your inbox





//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error:" . $mail->ErrorInfo;
} else {
    echo '<meta http-equiv="refresh" content="0;url=https://www.sucess.com/">';
}}



?>





</body>
</html>

1 Ответ

0 голосов
/ 23 марта 2020

Вы делаете одно и то же дважды, но неправильно (и неоправданно) во второй раз.

Этот метод создания экземпляра подходит для PHPMailer 6.0 и более поздних версий (хотя вы можете сделать так, чтобы он выглядел лучше, используя псевдоним). Обратите внимание на направление косых черт:

$mail = new PHPMailer\PHPMailer\PHPMailer();

Это то же самое, что сказать:

use PHPMailer\PHPMailer\PHPMailer;
...
$mail = new PHPMailer();

Позже в вашем коде вы делаете это (без более раннего use заявление):

$mail = new PHPMailer;

Это не сработает, если вы не объявите пространство имен PHPMailer или не импортируете имя класса с пространством имен в свое собственное пространство имен. Независимо от этого - это дубликат, и вы можете просто удалить эту строку.

Возможно, вы захотите прочитать руководство по обновлению, поставляемое с PHPMailer .

...