problemas con PHPmailer
Publicado por Nicolás (24 intervenciones) el 24/02/2017 16:21:11
Hola. Estoy implementando el envío de mail por PHPmailer. Lo estoy ocupando a través de localhost con TestMailServer como servidor de mails. Tengo el archivo php.ini bien configurado. En un mismo directorio tengo todos los archivos, los de phpmailer (class.phpmailer.php, PHPMailerAutoload.php, etc...) y mis propios archivos (form.HTML, smtp.php)
form.html
smtp.php
Cuando ejecuto el código aparece este error:
Parse error: syntax error, unexpected '$mail' (T_VARIABLE) in C:\xampp\htdocs\.......\smtp.php on line 4
Alguien me puede ayudar?
form.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE HTML>
<html lang="">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form action="smtp.php" method="post">
<h1>Formulario de Ejemplo</h1>
<label>Nombre</label>
<input type="text" name="nombre" /><br>
<label>Email</label>
<input type="email" name="correo" /><br>
<label>Comentarios</label>
<textarea name="comentarios"></textarea><br>
<input name="enviar" type="submit" value="Enviar" />
</form>
</body>
</html>
smtp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
require 'class.phpmailer.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = "localhost";
$mail->Port = 25;
$mail->SMTPAuth = false;
$mail->From = $_POST['correo']; //Remitente de Correo
$mail->FromName = $_POST['nombre']; //Nombre del remitente
$to = "postmaster@localhost"; //Para quien se le va enviar
$mail->AddAddress($to);
$mail->Subject = 'Prueba PHPMailer SMTP';
$mail->msgHTML(file_get_contents('form2.html'), dirname(__FILE__));
//$mail->MsgHTML($body);
$mail->IsHTML(true); // Enviar como HTML
$mail->Send();//Enviar
if (!$mail->send()) {
echo "Error: " . $mail->ErrorInfo;
} else {
echo "Correo enviado!";
}
//http://www.ideaschile.cl/correos-con-php-mailer-localhost.php
?>
Cuando ejecuto el código aparece este error:
Parse error: syntax error, unexpected '$mail' (T_VARIABLE) in C:\xampp\htdocs\.......\smtp.php on line 4
Alguien me puede ayudar?
Valora esta pregunta
0