-1

My mailer stopped working and I cant get it to work again. I downloaded the newest phpmailer 5.5 from githhub and recodeded the page . I used the examples to create my mailer and created my form and when I turned on error reporting I cant figure this error out. I looked at examples on ur site and the did not work i trued to use
Fatal error: Class 'PHPMailer' not found
my server is using PHP Version 7.3.15 with the corna virus this is essential for me to stay aflot can u help me???




<!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 Answers1

0

You're doing the same thing twice, but incorrectly (and unnecessarily) the second time.

This method of creating an instance is correct for PHPMailer 6.0 and later (though you can make it look better by using an alias). Note the direction of the slashes:

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

This is the same as saying:

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

Later in your code, you're doing this (without having an earlier use statement):

$mail = new PHPMailer;

This won't work unless you either declare the PHPMailer namespace, or import the namespaced class name into your own namespace. Regardless – this is a duplicate and you can simply delete this line.

You might want to read the upgrade guide provided with PHPMailer.

Synchro
  • 35,538
  • 15
  • 81
  • 104