Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/04/2013, 10:30
nataliagb1992
 
Fecha de Ingreso: septiembre-2012
Ubicación: Sevilla
Mensajes: 144
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: Enviar email con archiv adjunto en php

pero como lo hago???

como utilizo mi cuenta de gmail
mira lo que tengo es lo siguiente

Código HTML:
Ver original
  1. <div id="fact">      
  2.             <form accept-charset="utf-8" action="enviarcorreo.php" class="trabaja" enctype="multipart/form-data" id="formulario" method="post">
  3.  
  4.                 <input type="text" id="nombre" name="nombre" value="Nombre" />
  5.                 <input type="text" id="apellido" name="apellido" value="Apellidos" />
  6.                 <input type="text" id="email" name="email" value="e-mail" />
  7.                 <input type="text" id="telefono" name="telefono" value="Telefono" />
  8.                 <input type="file" id="filead" name="filead" />
  9.                        <input type="checkbox" id="condiciones" name="condiciones" />
  10.                     <input type="submit" value="Enviar Formulario" />
  11.  
  12.             </form>
Código PHP:
Ver original
  1. <?php
  2. if ($_POST) {
  3.  
  4.     $num = md5(time());
  5.  
  6. //MAIL BODY
  7.     $body = '';
  8.     ?>
  9.     <html>
  10.         <head>
  11.             <title>Formulario Trabaja con nosotros</title>
  12.         </head>
  13.         <body style = 'background:#EEE; padding:30px;'>
  14.             <h2 style = 'color:#767676;'>Trabaja con nosotros</h2>";
  15.             <?
  16.             $body .= "<strong style = 'color:#0090C6;'>Nombre: </strong>   <span style = 'color:#767676;'>" . $_POST["nombre"] . "</span>";
  17.  
  18.             $body .= "
  19.    <strong style = 'color:#0090C6;'>Apellidos: </strong>
  20.    <span style = 'color:#767676;'>" . $_POST["apellido"] . "</span>";
  21.  
  22.             $body .= "
  23.    <strong style = 'color:#0090C6;'>Email: </strong>
  24.    <span style = 'color:#767676;'>" . $_POST["email"] . "</span>";
  25.  
  26.             $body .= "
  27.    <strong style = 'color:#0090C6;'>Teléfono: </strong>
  28.    <span style = 'color:#767676;'>" . $_POST["telefono"] . "</span>";
  29.  
  30.             $body .= "</body></html>";
  31.  
  32.             $_name = $_FILES["filead"]["name"];
  33.             $_type = $_FILES["filead"]["type"];
  34.             $_size = $_FILES["filead"]["size"];
  35.             $_temp = $_FILES["filead"]["tmp_name"];
  36.  
  37.             if (strcmp($_name, "")) { //FILES EXISTS
  38.                 $fp = fopen($_temp, "rb");
  39.                 $file = fread($fp, $_size);
  40.                 $file = chunk_split(base64_encode($file));
  41.  
  42. // MULTI-HEADERS Content-Type: multipart/mixed and Boundary is mandatory.
  43.                 $headers = "From: [email protected] >\r\n";
  44.                 $headers .= "MIME-Version: 1.0\r\n";
  45.                 $headers .= "Content-Type: multipart / mixed;
  46.    ";
  47.                 $headers .= "boundary = " . $num . "\r\n";
  48.                 $headers .= "--" . $num . "\n";
  49.  
  50. // HTML HEADERS
  51.                 $headers .= "Content-Type: text / html;
  52.    charset = UTF-8\r\n";
  53.                 $headers .= "Content-Transfer-Encoding: 8bit\r\n";
  54.                 $headers .= "" . $body . "\n";
  55.                 $headers .= "--" . $num . "\n";
  56.  
  57. // FILES HEADERS
  58.                 $headers .= "Content-Type:application/octet-stream ";
  59.                 $headers .= "name = \"" . $_name . "\"r\n";
  60.                 $headers .= "Content-Transfer-Encoding: base64\r\n";
  61.                 $headers .= "Content-Disposition: attachment; ";
  62.                 $headers .= "filename=\"" . $_name . "\"\r\n\n";
  63.                 $headers .= "" . $file . "\r\n";
  64.                 $headers .= "--" . $num . "--";
  65.             } else { //FILES NO EXISTS
  66. // HTML HEADERS
  67.                 $headers = "From: NataliaCorreo \r\n";
  68.                 $headers .= "MIME-Version: 1.0\r\n";
  69.                 $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  70.                 $headers .= "Content-Transfer-Encoding: 8bit\r\n";
  71.             }
  72.  
  73. // SEND MAIL
  74.             mail("[email protected]", "Prueba Correo", $body, $headers);
  75.  
  76.             echo "<div class='ok'><strong>El formulario se ha enviado correctamente.</strong></div>";
  77.         }
  78.         ?>
pero he hecho la prueba y no me funciona