Hi, I have the following code, what I want to do is walk an email with the class PHPMailer but I get an error:
Fatal error: Uncaught Error: Class 'SMTP' not found in C: \ xampp \ htdocs \ project \ clients \ phpmailer \ class.phpmailer.php: 1466 Stack trace: # 0 C: \ xampp \ htdocs \ project \ clients \ phpmailer \ class.phpmailer.php (1549): PHPMailer-> getSMTPInstance () # 1 C: \ xampp \ htdocs \ project \ clients \ phpmailer \ class.phpmailer.php (1486): PHPMailer-> smtpConnect ( Array) # 2 C: \ xampp \ htdocs \ project \ clients \ phpmailer \ class.phpmailer.php (1323): PHPMailer-> smtpSend ('Date: Fri, 10 M ...', 'This is a multi. .. ') # 3 C: \ xampp \ htdocs \ project \ clients \ phpmailer \ class.phpmailer.php (1203): PHPMailer-> postSend () # 4 C: \ xampp \ htdocs \ project \ clients \ federal \ administrator \ mail.php (22): PHPMailer-> send () # 5 {main} thrown in C: \ xampp \ htdocs \ project \ clients \ phpmailer \ class.phpmailer.php on line 1466
and my code is as follows:
<?php
require("../../phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "localhost";
// SMTP a utilizar. Por ej. smtp.elserver.com
$mail->Username = "root"; // Correo completo a utilizar
$mail->Password = ""; // Contraseña
$mail->Port = 25; // Puerto a utilizar
$mail->From = "[email protected]"; // Desde donde enviamos (Para mostrar)
$mail->FromName = "ELSERVER.COM";
$mail->AddAddress("correo"); // Esta es la dirección a donde enviamos
$mail->AddCC("[email protected]"); // Copia
$mail->AddBCC("[email protected]"); // Copia oculta
$mail->IsHTML(true); // El correo se envía como HTML
$mail->Subject = "Titulo"; // Este es el titulo del email.
$body = 'Hola mundo. Esta es la primer línea<br />';
$body .= "Acá continuo el<strong>mensaje</strong>";
$mail->Body = $body; // Mensaje a enviar
$mail->AltBody = "Hola mundo. Esta es la primer línean Acá continuo el mensaje"; // Texto sin html
$mail->AddAttachment("imagenes/imagen.jpg", "imagen.jpg");
$exito = $mail->Send(); // Envía el correo.
if($exito){
echo "El correo fue enviado correctamente.";
} else {
echo "Hubo un inconveniente. Contacta a un administrador.";
}
?>