title: Uncaught Error: Class 'PHPMailer\PHPMailer\Exception' not found in C
body: <p>I am unable to receive confirmation emails because of the error. Here is my PhpMailer error on the line.</p>
  
  <p>Fatal error: Uncaught Error: Class 'PHPMailer\PHPMailer\Exception' not found in C:\xampp\htdocs\Web\PHPMailer\PHPMailer.php:1703 Stack trace: #0 C:\xampp\htdocs\Web\PHPMailer\PHPMailer.php(1515): PHPMailer\PHPMailer\PHPMailer->mailSend('Date: Wed, 25 J...', '\r\n ...') #1 C:\xampp\htdocs\pificy\PHPMailer\PHPMailer.php(1352): PHPMailer\PHPMailer\PHPMailer->postSend() #2 C:\xampp\htdocs\Web\1r.php(43): PHPMailer\PHPMailer\PHPMailer->send() #3 {main} thrown in C:\xampp\htdocs\pificy\PHPMailer\PHPMailer.php on line 1703. </p>
  
  <p>Below is the line that I'm getting the error on. What should I do?</p>
  
  <pre><code>if (!$result) {
  throw new Exception($this-&gt;lang('instantiate'), self::STOP_CRITICAL);
      }
  </code></pre>
  
  <p>To be more specific this is my code for the register file:</p>
  
  <pre><code>&lt;?php
  $msg = "";
  use PHPMailer\PHPMailer\PHPMailer;
  use PHPMailer\PHPMailer\Exception;
  
  if (isset($_POST['submit'])) {
      $con = new mysqli('localhost', 'Owner', '', 'Pificy');
  
  $username = $con-&gt;real_escape_string($_POST['username']);
  $email = $con-&gt;real_escape_string($_POST['email']);
  $password = $con-&gt;real_escape_string($_POST['password']);
  $cPassword = $con-&gt;real_escape_string($_POST['cPassword']);
  
  if ($username == "" || $email == "" || $password != $cPassword)
          $msg = "Please check your inputs!";
  else {
  $sql = $con-&gt;query("SELECT id FROM users WHERE email='$email'");
  if ($sql-&gt;num_rows &gt; 0) {
  $msg = "Email already exists in the database!";
  } else {
  $token 'qwertzuiopasdfghjklyxcvbnmQWERTZUIOPASDFGHJKLYXCVBNM0123456789!$/()*';
  $token = str_shuffle($token);
  $token = substr($token, 0, 10);
  
  $hashedPassword = password_hash($password, PASSWORD_BCRYPT);
  
  $con-&gt;query("INSERT INTO users (username,email,password,isEmailConfirmed,token)
  VALUES ('$username', '$email', '$hashedPassword', '0', '$token');
              ");
  
  include_once "PHPMailer/PHPMailer.php";
  
  $mail = new PHPMailer();
  $mail-&gt;setFrom('NotForUtoKnow@gmail.com');
  $mail-&gt;addAddress($email, $username);
  $mail-&gt;Subject = "Please verify email!";
  $mail-&gt;isHTML(true);
  $mail-&gt;Body = "
  Please click on the link below:&lt;br&gt;&lt;br&gt;
  
  &lt;a href='http://Upcoming.com/Upcoming/confirm.php?email=$email&amp;token=$token'&gt;Click Here&lt;/a&gt;
              ";
  
  if ($mail-&gt;send())
  $msg = "You have been registered! Please verify your email!";
              else
  $msg = "Something wrong happened! Please try again!";
  }
  }
  }
  ?&gt;
  </code></pre>