0
votes

..\www\solicitudes\index.php

..\www\solicitudes\conexion.php

..\www\solicitudes\PHPMailer\all the files descompressed from the downloaded zip https://github.com/PHPMailer/PHPMailer

I am having troubles instantiating the PHPMailer class, in conexion.php file I write the following line:

require_once('PHPMailer/PHPMailerAutoload.php');

and this error is showed

Fatal error: Class 'PHPMailer' not found in C:\AppServ\www\SolicitudesBE\conexion.php on line 58

I have changed the locatation of the file without success

                 require_once('PHPMailer/PHPMailerAutoload.php');
                //require_once('PHPMailer/class.phpmailer.php');        

                $mail = new PHPMailer;                  

                $mail->IsSMTP();
                //$mail->SMTPDebug = 2; 
                $mail->SMTPAuth = false; 
                $mail->SMTPSecure = "tls";  
                $mail->Host = "correo.domain.org.mx";   
                $mail->Port = 25;
                $mail->Username = "[email protected]";
                $mail->Password = "pass";
                $mail->SetFrom('[email protected]', 'Julio Castor');
                $mail->Subject = $asunto;   

Has any body can help me with this issue? By the way, this project works fine in others computers as server (local) but when I upload to the server (Windows server 2003) the error is showed.

I cannot get access to the server yet but as I can, where could I look for to configure the server?

4
It must be the path issue in your server . Check it . - Drudge Rajen
do you mean \\IP\www\SolicitudesBE\PHPMailer or C:\AppServ\www\SolicitudesBE\PHPMailer? I have tried both... No one of them works - July
first find the abosulte path to your file, and then use it . - Drudge Rajen
C:\AppServ\www\SolicitudesBE\PHPMailer\PHPMailerAutoload.php this is the path that I write in require_once but dont make any change, the same error, and the files downloaded are in the same path - July
Set a breakpoint in the autoloader and you'll see why it's not finding the files. Why are you not using composer? - Synchro

4 Answers

1
votes

try to include

use PHPMailer\PHPMailer\PHPMailer;
0
votes

Try

require_once(__DIR__ . '/PHPMailer/PHPMailerAutoload.php');

where DIR is the path of the current file.

0
votes

The issue is resolved, I changed the server (Appserver) with XAMPP (version for windows server 2003) the error was not about the code, it was the server (maybe could be the composer dependecies). Anyway, it is working! Thanks for your assistancce

-1
votes

Try using,

require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'PHPMailer' . DIRECTORY_SEPARATOR . 'PHPMailerAutoload.php');

if not works try,

require_once('PHPMailer/class.phpmailer.php');
require_once('PHPMailer/class.phpmaileroauth.php');
require_once('PHPMailer/class.phpmaileroauthgoogle.php');
require_once('PHPMailer/class.pop3.php');
require_once('PHPMailer/class.smtp.php');

I hope this will work.