如何使用XAMPP测试PHP Mailer代码?

Basically, I have tested other PHP codes before using XAMPP but I want to test this code that sends an email to my gmail account using XAMPP. What are the steps to take to test to see if the email will send.

My PHP Code:

<?php
header('Content-type: application/json');
$status = array(
    'type'=>'success',
    'message'=>'Thank you for contact us. As early as possible  we will contact you '
);

//Added to deal with Files
require_once('./PHPMailer/class.phpmailer.php')
    //Get the uploaded file information
    $name_of_uploaded_file =
        basename($_FILES['uploaded_file']['name']);

    //get the file extension of the file
    $type_of_uploaded_file =
        substr($name_of_uploaded_file,
        strrpos($name_of_uploaded_file, '.') + 1);

    $size_of_uploaded_file =
        $_FILES["uploaded_file"]["size"]/1024;//size in KBs

    //Settings
    $max_allowed_file_size = 10240; // size in KB
    $allowed_extensions = array("jpg", "jpeg", "gif", "bmp","png");

    //Validations
    if($size_of_uploaded_file > $max_allowed_file_size )
    {
      $errors .= "
 Size of file should be less than $max_allowed_file_size (~10MB). The file you attempted to upload is too large. To reduce the size, open the file in an image editor and change the Image Size and resave the file.";
    }

    //------ Validate the file extension -----
    $allowed_ext = false;
    for($i=0; $i<sizeof($allowed_extensions); $i++)
    {
      if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
      {
        $allowed_ext = true;
      }
    }

    if(!$allowed_ext)
    {
      $errors .= "
 The uploaded file is not supported file type. ".
      " Only the following file types are supported: ".implode(',',$allowed_extensions);
    }

    //copy the temp. uploaded file to uploads folder - make sure the folder exists on the server and has 777 as its permission
    $path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
    $tmp_path = $_FILES["uploaded_file"]["tmp_name"];

    if(is_uploaded_file($tmp_path))
    {
      if(!copy($tmp_path,$path_of_uploaded_file))
      {
        $errors .= '
 error while copying the uploaded file';
      }
    }

//------------------------
$name = @trim(stripslashes($_POST['name'])); 
$clientemail = @trim(stripslashes($_POST['email'])); 
$subject = @trim(stripslashes($_POST['subject'])); 
$message = @trim(stripslashes($_POST['message']));

$body = 'Name: ' . $name . "

" . 'Email: ' . $clientemail . "

" . 'Subject: ' . $subject . "

" . 'Message: ' . $message;

$email = new PHPMailer();
$email->From      = $clientemail;
$email->FromName  = $name;
$email->Subject   = $subject;
$email->Body      = $body;  
$email->AddAddress( 'Badrush@gmail.com' ); //Send to this email

$file_to_attach = 'PATH_OF_YOUR_FILE_HERE';

$email->AddAttachment( $path_of_uploaded_file , $name_of_uploaded_file );

return $email->Send();

echo json_encode($status);
die;

Update:

I downloaded FakeSMTP but I don't know how to get XAMPP local server and the fakeSMTP server to talk...

Link to FakeSMTP: http://nilhcem.github.io/FakeSMTP/project-reports.html

To Sending Mail through PHP mailer Code you Should Enable Following feature in your local server

  1. PHP_OPENSSL
  2. PHP_SMTP
  3. PHP_SOCKETS

and then use this Code

$filename="Important-Notice.docx"; // file name if you want to send attachment
$message=" <h2>Your Testing Mesage</h2>";// You Can Use HTML code inside    
include "Classes/class.phpmailer.php"; // include the class name
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "your_gmail_username@gmail.com";
$mail->Password = "Your_password";//Your password Key
$mail->SetFrom("info@myourwebsite.com");
$mail->Subject = "Your Gmail SMTP Mail";
$mail->Body = $message;
$mail->AddAddress($email);
$mail->AddBCC("another_mail_2@gmail.com");
$fileatt= "notes/".$filename;//Your Attachment Location
$mail->AddAttachment($fileatt);


 if(!$mail->Send()){
    echo "Mailer Error: " . $mail->ErrorInfo;
}
else{
    //echo "Message has been sent";
}