Tema: mail con PHP
Ver Mensaje Individual
  #8 (permalink)  
Antiguo 11/08/2010, 15:13
jen26
 
Fecha de Ingreso: marzo-2010
Mensajes: 152
Antigüedad: 14 años, 1 mes
Puntos: 1
Respuesta: mail con PHP

La verdad no la he buscado lo que hice fue descargar el Free SMTP Server y tengo el siguiente codigo:
Código PHP:
Ver original
  1. <?php
  2. $aviso = "";
  3. // check form  
  4. if ($_POST['email'] != "") {
  5.     // email de destino
  6.     $email = $_POST['email'];
  7.    
  8.     // asunto del email
  9.     $subject = "Contacto";
  10.    
  11.     // Cuerpo del mensaje
  12.     $mensaje = "---------------------------------- \n";
  13.     $mensaje.= "            Contacto               \n";
  14.     $mensaje.= "---------------------------------- \n";
  15.     $mensaje.= "NOMBRE:   ".$_POST['nombre']."\n";
  16.     $mensaje.= "EMPRESA:  ".$_POST['empresa']."\n";
  17.     $mensaje.= "EMAIL:    ".$_POST['email']."\n";
  18.     $mensaje.= "TELEFONO: ".$_POST['telefono']."\n";
  19.     $mensaje.= "FECHA:    ".date("d/m/Y")."\n";
  20.     $mensaje.= "HORA:     ".date("h:i:s a")."\n";
  21.     $mensaje.= "IP:       ".$_SERVER['REMOTE_ADDR']."\n\n";
  22.     $mensaje.= "---------------------------------- \n\n";
  23.     $mensaje.= $_POST['mensaje']."\n\n";
  24.     $mensaje.= "---------------------------------- \n";
  25.     $mensaje.= "Enviado desde http://tupagina.com \n";
  26.    
  27.     // headers del email
  28.     $headers = "From: ".$_POST['email']."\r\n";
  29.    
  30.     // Enviamos el mensaje
  31.     if (mail($email, $subject, $mensaje, $headers)) {
  32.         $aviso = "Su mensaje fue enviado correctamente";
  33.     } else {
  34.         $aviso = "Error de envío";
  35.     }
  36. }
  37. ?>
  38. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  39. <html xmlns="http://www.w3.org/1999/xhtml">
  40. <head>
  41. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  42. <title>Enviar Email</title>
  43. <style type="text/css">
  44. body {
  45.     margin: 16px;
  46.     padding: 0;
  47.     font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  48.     font-size: 12px;
  49.     color: #333;   
  50. }
  51. input, textarea {
  52.     float: left;
  53.     font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  54.     font-size: 12px;
  55.     color: #333;
  56.     padding: 2px;
  57.     width: 250px;
  58.     margin-bottom: 4px;
  59. }
  60. label {
  61.     float: left;
  62.     width: 100px;
  63. }
  64. button {
  65.     width: 80px;
  66.     background: #333;
  67.     color: #FFF;
  68.     padding: 3px 8px;
  69. }
  70. form {
  71.     border: solid 1px #CCC;
  72.     background: #efefef;
  73.     padding: 16px;
  74.     width: 380px;
  75. }
  76. br { clear: both; }
  77. em { color: red; }  
  78. </style>
  79. </head>
  80. <body>
  81. <h2>Enviar Email con PHP</h2>
  82. <?php if ($aviso != "") { ?>
  83. <p><em><?php echo $aviso; ?></em></p>
  84. <?php } ?>
  85. <form action="" method="post">
  86.     <label for="nombres">Nombres</label> <input name="nombre" id="nombre" type="text" /><br />
  87.     <label for="empresa">Empresa</label> <input name="empresa" id="empresa" type="text" /><br />
  88.     <label for="email">Email</label> <input name="email" id="email" type="text" /><br />
  89.     <label for="telefono">Telefono</label> <input name="telefono" id="telefono" type="text" /><br />
  90.     <label for="mensaje">Mensaje</label> <textarea name="mensaje" cols="30" rows="6"></textarea><br />
  91.     <label for="btsend">&nbsp;</label> <button name="btsend" id="btsend" type="submit">Enviar</button>
  92. </form>
  93. </body>
  94. </html>

pero me lanza este errior:

Warning: mail() [function.mail]: SMTP server response: 550 Invalid recipient: [email protected]


bueno intentare trabajar con la clase pero es q no tengo mucha experiencia =(