使用include语句后,新手到OOP无法访问类属性

I want pass a variable to a property inside a class I just used in a a include statement How do I do that. This is what I have (not working) tclass.php mail program calls the class is nspace.php In tclass.php I am trying to pass variables to the class, this is a test.

tclass.php

<?php
   include_once('C:\xampp\htdocs
space3.php');
   $mail->setFrom("jperson19468@gmail.com", "Mailer");
?>

nspace3.php

<?php
namespace MyProject;

use PHPMailer\PHPMailer\Exception;

use C\xampp\htdocs\PHPMailer\src\SMPT;

use PHPMailer\PHPMailer\PHPMailer;

require 'C:\xampp\htdocs\PHPMailer\src\PHPMailer.php';

require 'C:\xampp\htdocs\PHPMailer\src\SMPT.php';

require 'C:\xampp\htdocs\PHPMailer\src\Exception.php';

$mail = new PHPMailer;(true);

try {
    //Server settings

    $mail->SMTPDebug = 0;             // Enable verbose debug output

    $mail->isSMTP();                  // Set mailer to use SMTP

    $mail->Host = 'smtp.gmail.com';   // Specify main and backup SMTP servers

    $mail->SMTPAuth = true;           // Enable SMTP authentication

    $mail->Username = 'xxxxxxxxxx'    // SMTP username

    $mail->Password = 'xxxxxxx';      // SMTP password

    $mail->SMTPSecure = 'tls';     // Enable TLS encryption, `ssl` also accepted

    $mail->Port = 587;              // TCP port to connect to

    //Recipients
 //  $mail->setFrom('jperson19468@gmail.com', 'Mailer'); <==== Line trying to access in tclassfile

    $mail->addAddress('jperson19468@gmail.com', 'Joe User'); // Add a recipient

    //Content
    $mail->isHTML(true);                   // Set email format to HTML
    $mail->Subject = 'Here is a Test3';
    $mail->Body    = 'I hope this works <b>It works!!</b>';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {

    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
}

?>

You create the $mail object and sent the email in nspace3.php, only after that you are calling the setFrom which will not work since the mail already sent. So i suggest pass those data to nspace3 instead.

<?php
   $from = "jperson19468@gmail.com" ;
   $mailer = "Mailer" ;
   include_once('C:\xampp\htdocs
space3.php');
?>

in nspace3.php

//Recipients
$mail->setFrom($from, $mailer ); <==== Line trying to access in tclassfile