0

The below code is in PHP:

class Email
{
    private $mail,$to,$subject,$body;
    function __construct()
    {
        require_once "phpmailer1/src/PHPMailer.php";
        require_once "phpmailer1/src/SMTP.php";
        require_once "phpmailer1/src/POP3.php";
        $this->mail = new PHPMailer(true);
        $this->mail->isSMTP();
        $this->mail->Host = "smtp.gmail.com";
        $this->mail->Username = "emailaddress";
        $this->mail->Password = "password";
        $this->mail->SMTPSecure = "tls";
        $this->mail->Port = 587;
        $this->to = "0";
        $this->subject = "0";
        $this->body = "0";
        $this->mail->SMTPAuth = true;
        $this->mail->setFrom("new address email","hello");
        $this->mail->CharSet = "utf-8";
        $this->mail->SMTPOptions = array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        )
        );
    }
    function ToEmail($getmail)
    {
        $this->to = $getmail;
    }
    function SubjectMail($submail)
    {
        $this->subject = $submail;
    }
    function BodyMail($bodymail)
    {
        $this->body = $bodymail;
    }
    function Send()
    {
        if($this->to != "0" && $this->subject != "0" && $this->body != "0")
        {
            $this->mail->addAddress($this->to,"hello");
            $this->mail->subject = $this->subject;
            $this->mail->msgHTML($this->body);
            if($this->mail->send())
            {
                echo "Email Send";
            }
            else
            {
                echo "Email Not Send";
            }
        }
        else
        {
            echo "230";
        }
    }
};

I want to use the new version of PHPMailer but when I want to run it I see

Fatal error: Uncaught Error: Class 'PHPMailer' not found in C:\xampp\htdocs\xampp\khunehyab\email\mainemail.php:13 Stack trace: #0 C:\xampp\htdocs\xampp\khunehyab\email\mainemail.php(69): Email->__construct() #1 {main} thrown in what do i do?? please help me my PHPMailer is v6.0.1

RSS
  • 23
  • 8
  • Possible Duplicate of https://stackoverflow.com/questions/44843305/how-to-integrate-phpmailer-with-codeigniter-3 – TimBrownlaw Nov 18 '17 at 21:33

1 Answers1

0

You need to use a fully-qualified class name (FQCN) of PHPMailer\PHPMailer\PHPMailer, or import it into your namespace with use PHPMailer\PHPMailer\PHPMailer; at the top of your file.

Synchro
  • 35,538
  • 15
  • 81
  • 104