I'm trying to send an email through a contact form from PHPMAILER and sending get the following error (I'm working from Localhost).
Could not access file: SMTP Error: Could not connect to SMTP host.
This is my code
//Libs
include_once('class.phpmailer.php');
include_once('class.smtp.php');
//Receive all the parameters of the form
$para = $_POST['email'];
$asunto = $_POST['asunto'];
$mensaje = $_POST['mensaje'];
$archivo = $_FILES['hugo'];
//this block is important
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 25;
//our account
$mail->Username ='mail@gmail.com';
$mail->Password = '******';
//Add destinatary
$mail->AddAddress($para);
$mail->Subject = $asunto;
$mail->Body = $mensaje;
//Para adjuntar archivo
$mail->AddAttachment($archivo['tmp_name'], $archivo['name']);
$mail->MsgHTML($mensaje);
//Avisar si fue enviado o no y dirigir al index
if($mail->Send())
{
echo'<script type="text/javascript">
alert("Enviado Correctamente");
window.location="http://localhost/maillocal/index.php"
</script>';
}
else{
echo'<script type="text/javascript">
alert("NO ENVIADO, intentar de nuevo");
window.location="http://localhost/maillocal/index.php"
</script>';
}
help (Y)