Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/07/2009, 14:31
zxs23
 
Fecha de Ingreso: mayo-2009
Mensajes: 238
Antigüedad: 15 años
Puntos: 7
Desacuerdo Respuesta: hola nesecito un codigo para enviar mensajes e-mail desde mi web

Este codigo funciona, ahora si no tienes un host que tenga php y la funcion mail habilitada no puedes hacer nada, no digas que no funciona por si corre.

formulario.htm
Código:
<html>
<body>
      <form action="send.php" method="post" name="form1">
	  <table width="503" border="0" bgcolor="#F2F2E6" cellpadding="0" cellspacing="0">
        <tr>
          <td height="35" colspan="3" align="center"><b>Formulario</b></td>
        </tr>
        <tr>
          <td width="124" height="33" align="right"><b>Nombre :</b></td>
          <td colspan="2"><input name="nombre" id="nombre" type="text"></td>
        </tr>
        <tr>
          <td height="37" align="right"><b>E-Mail :</b></td>
          <td colspan="2"><input name="email" id="email" type="text"></td>
        </tr>
        <tr>
          <td height="109" align="right" valign="top"><b>Mensaje :</b></td>
          <td colspan="2" valign="top"><textarea name="comentario" id="textarea" rows="5" cols="40"></textarea></td>
        </tr>
        <tr>
          <td colspan="3" align="center"><input type="submit" name="submit" id="submit3" value="Enviar mensaje" /></td>
        </tr>
      </table>
      </form>
</body>
</html>
send.php
Código:
<?
$nombre= $_POST['nombre'];
$email = $_POST['email'];
$comentario = $_POST['comentario'];
$titulo= "Mensaje web";

$headers = "MIME-Version: 1.0 \r\n";  
$headers .= "Content-type: text/html; charset=iso-8859-1 \r\n"; 
$headers .= "From: $email \r\n";   
$headers .= "X-Priority: 1 \r\n";  //1 urgente 5 no urgente 3 default
$headers .= "X-MSMail-Priority: High \r\n";  

$mensaje = "Nombre : ";
$mensaje .= $nombre;
$mensaje .="<br>";
$mensaje .= $comentario;

#Destinatario
$target= "[email protected]";

if (mail($target,$titulo,$mensaje,$headers)){
#echo "Mensaje enviado correctamente";
header('Location:ok.htm');
}
else{
#echo "fallo";
header('Location:error.htm');
}
?>
Si alguien necesita ayuda por algunos $$$ les ayudo