Phpmailer Fatal error: Class 'SMTP' not found in

1

I am trying to send an email using the phpmailer class, however I have not managed it so far. I have tried several options and combinations within the code and even see if the problem is not found in the php.ini file but I have only achieved the following.

  

Fatal error: Class 'SMTP' not found in "c: \ xampp \ miruta \ phpmailer \ class.phpmailer.php on line 1520"

So far what I have managed to conclude is that it just does not find the class " class.smtp.php " so I manually included it with a include/require , but it did not work anymore that when trying to send the mail the request was hung and I do not send anything.

On the other hand I found that it was wrong to include the class " class.smtp.php " manually and it had to be done using the Autoload to try with the autoload " PHPMailerAutoload.php ", the result was the same where the request hangs and does not send anything.

Does anyone know what is happening?

This is my code, the commented lines are attempts and combinations that I was making, just leave the part where I am left hanging with the autoload

    $nombre=htmlspecialchars($_POST['nombre']);
    $email=htmlspecialchars($_POST['email']);
    $asunto=htmlspecialchars($_POST['asunto']);
    $mensaje=$_POST['mensaje'];

    require ("../phpmailer/PHPMailerAutoload.php");

    // include ("../phpmailer/class.smtp.php");
    // include ("../phpmailer/class.phpmailer.php");

    // require_once ("../phpmailer/PHPMailerAutoload.php");
    // include ("../phpmailer/class.smtp.php");

    // require ("../phpmailer/PHPMailerAutoload.php");
    // require ("../phpmailer/class.smtp.php");

    $mail=new PHPMailer;
    $mail->IsSMTP();
    $mail->SMTPAuth=true;
    $mail->SMTPSecure = 'ssl';
    $mail->Host='smtp.gmail.com';
    $mail->Port='465';
    $mail->Username='[email protected]';
    $mail->Password='mipass';       
    $mail->From='[email protected]';
    $mail->FromName='Administrador';
    $mail->Subject=$asunto;
    $mail->AddAddress($email,$nombre);
    $mail->MsgHTML($mensaje);

    if($mail->Send())
    {
        $msg='Se ha enviado el mensaje a '.$email;
    }
    else
    {
        $msg='Ha habido un error al enviar el correo a '.$email;
        echo 'Error Mail '.$mail->ErrorInfo;
    }

On the other hand, the part of the php.ini I have with these changes that I do not see any problem unless it is missing some detail:

[mail function]  
SMTP=localhost:8012  
smtp_port=465  

Thanks and regards

    
asked by Alex 20.03.2017 в 18:22
source

0 answers