I am trying to configure the sending of mail with php through the PHPMailer class. When I execute the function that should send the mail I get the following error:
Warning: Creating default object from empty value in .......... on line 23
6
line 236 is this: $mail->SMTPDebug = 2;
the full code of the function is this:
[email protected];
$us=Pablo;
mailActivacion($email,$us);
function mailActivacion($dir_correo, $usuario){
require_once('../PHPMailer/class.phpmailer.php');
//require_once('../PHPMailer/class.smtp.php');
$mail = new PHPMailer();
//indico a la clase que use SMTP
$mail->IsSMTP();
//permite modo debug para ver mensajes de las cosas que van ocurriendo
$mail->SMTPDebug = 2;
//Debo de hacer autenticación SMTP
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
//indico el servidor de Gmail para SMTP
$mail->Host = "smtp.gmail.com";
//indico el puerto que usa Gmail
$mail->Port = 465;
//indico un usuario / clave de un usuario de gmail
$mail->Username = "[email protected]";
$mail->Password = "123456789";
$mail->SetFrom('[email protected]', 'Mi Nombre');
$mail->AddReplyTo("[email protected]","Mi Nombre");
$mail->Subject = "Envío de email usando SMTP de Gmail";
$mail->MsgHTML("Hola que tal, esto es el cuerpo del mensaje!");
//indico destinatario
$address = $dir_correo;
$mail->AddAddress($address, $usuario);
if(!$mail->Send()) {
echo "Error al enviar: " . $mail>ErrorInfo;
} else {
echo "Mensaje enviado!";
}
}