TODOPIC

Misceláneas - Interés General => Off Topic => Mensaje iniciado por: Leon Pic en 30 de Octubre de 2011, 19:53:28

Título: Problemas para enviar e-mail con wapserver 5.3 en lenguaje php
Publicado por: Leon Pic en 30 de Octubre de 2011, 19:53:28
Hola gente.
Estoy estudiando programación PHP y MySQL con el libro "Desarrollo web con PHP y MySQL" de Luke Welling y Laura Thomson. Resulta que en el capítulo 4, se trata de enviar un e-mail, pero a la hora de ejecutar el scrin php, este me genera el siguiente error:

Código: [Seleccionar]
Notice: Undefined index: name in C:\wamp\www\php\processfeedback.php on line 3

Notice: Undefined index: email in C:\wamp\www\php\processfeedback.php on line 4

Notice: Undefined index: feedback in C:\wamp\www\php\processfeedback.php on line 5

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\php\processfeedback.php on line 19
Feedback submitted

Su comentario ha sido enviado correctamente.

Las líneas 3; 4 y 5 son las siguientes:

Código: [Seleccionar]
$name=$_POST['name'];
$email=$_POST['email'];
$feedback=$_POST['feedback'];

Y la línea 19 es:

Código: [Seleccionar]
mail($toaddress, $subject, $mailcontent, $fromaddress);
Estoy utilizando el wapserver 5.3
Leí que hay que modificar el archivo php.ini con lo siguiente:

Código: [Seleccionar]
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = soporte@meteorologiafacil.com.ar

pero nada, me sigue apareciendo el error antes citado.

Por si lo necesita, el siguiente es todo el scrim completo:

Código: [Seleccionar]
<?php
//Crear nombre de las variables.
$name=$_POST['name'];
$email=$_POST['email'];
$feedback=$_POST['feedback'];

//Establecer alguna información básica.
$toaddress "mi_email@meteorologiafacil.com.ar";

$subject "Comentario del sitio web";

$mailcontent "Customer name:" .$name."\n".
"Customer email:" .$email."\n".
"Customer comments: \n".$feedback."\n";

$fromaddress "From: soporte@meteorologiafacil.com.ar";

//Llamar a la función mail() para enviar correo
mail($toaddress$subject$mailcontent$fromaddress);

?>

<html>
<head>
<title>Bob's Auto partes - Feedback Submitted</title>
</head>
<body>
<h1>Feedback submitted</h1>
<p>Su comentario ha sido enviado correctamente.</p>
</body>
</html>
Título: Re: Problemas para enviar e-mail con wapserver 5.3 en lenguaje php
Publicado por: Leon Pic en 30 de Octubre de 2011, 20:13:56
Logré encontrar una solución de las líneas 3; 4 y 5.
Resulta que yo estaba ejecutando, desde el navegador, el scrim processfeedback.php y tenía que ejecutar el archivo feedback.html

Este error tonto, es culpa del libro, jamás me dio el código de este scrim (feedback.html).
Se los copio a continuación:

Código: [Seleccionar]
<html>
<head><title>Bob's Auto Parts - Customer Feedback</title></head>
<body>

<h1>Customer Feedback</h1>
<p>Please tell us what you think.</p>

<form action="processfeedback.php" method="post">

<p>Your name:<br/>
<input type="text" name="name" size="40" /></p>
     
<p>Your email address:<br/>
<input type="text" name="email" size="40" /></p>
     
<p>Your feedback:<br/>
<textarea name="feedback" rows="8" cols="40" wrap="virtual" /></textarea></p>
     
<p><input type="submit" value="Send feedback" /></p>

</form>


</body>
</html>

Ahora me falta solucionar el error de la línea 19:

Código: [Seleccionar]
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\php\processfeedback.php on line 19
Feedback submitted

Y el la línea 19:

Código: [Seleccionar]
mail($toaddress, $subject, $mailcontent, $fromaddress);
Título: Re: Problemas para enviar e-mail con wapserver 5.3 en lenguaje php
Publicado por: Geo en 30 de Octubre de 2011, 21:24:36
Para poder enviar correo necesitas un servidor de correo, checa si wampserver lo incluye, yo no recuerdo :p.