elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Problemas con envio de email en php
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Problemas con envio de email en php  (Leído 3,008 veces)
carnicero666

Desconectado Desconectado

Mensajes: 28


Ver Perfil
Problemas con envio de email en php
« en: 4 Abril 2009, 02:30 am »

Que tal amigos del foro cree un form para el vio de un email, pero lo unico que me llega es el nombre del mail, y no llega ni el nombre, mail, telefono, direccion  este es el codigo del form:

  <form id="form" name="form1" method="post" action="gracias.php">
      <p>
        <label><span class="style3"><span class="style4"><br />
        </span></span><span class="style12">&nbsp;&nbsp;&nbsp;Nombre:</span>&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="text" size="50" name="nombre" id="nombre" />
        </label>
</p>
      <p>
        <label><span class="style12">&nbsp;&nbsp;&nbsp;Domicilio:</span>
        <input name="domicilio" size="50" type="text" id="domicilio" value="" maxlength="60" />
        </label>
      </p>
      <p>
        <label><span class="style12">&nbsp;&nbsp;&nbsp;Telefono:</span>&nbsp;&nbsp;
        <input type="text"  size="50" name="telefono" id="telefono" />
        </label>
      </p>
      <p>
        <label><span class="style9">&nbsp;&nbsp;&nbsp;E-mail:</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="text" size="50" name="mail" id="mail" />
        </label>
      </p>
    </form>
Este el codigo del gracias.php:

<?php
$msg = "";
$field_name = array_keys($HTTP_POST_VARS); // guardamos todos los nombres de los "fields" existentes en el formulario
$value_name = array_values($HTTP_POST_VARS);// guardamos todos los valores en sus respectivas variables

for ($i=0;$i<count($field_name);$i++)
   {
   $msg .= "".$field_name[$i].": ".$value_name[$i]."\n"; // $msg reune el nombre de la variable y su valor
   }

$recipient = "mail@server.com"; // el mail deseado
$subject = "Registro"  "\n" ; // el titulo del mail
$mailheaders = "From: " .$nombre; // quien lo manda y el dominio
$mailheaders .= "Reply-To: ".$mail."\n\n";   // responder a: Importante! si quieres que el replay:to funcione tienes
                                 //que tener en el formulario un field que tiene como nombre "mail".

mail($recipient, $subject, $msg, $mailheaders);// mandamos el mail con los todos los datos

?>

si alguien me pudiera ayudar, se lo agradecería.


En línea

YST


Desconectado Desconectado

Mensajes: 965


I'm you


Ver Perfil WWW
Re: Problemas con envio de email en php
« Respuesta #1 en: 4 Abril 2009, 05:09 am »

Código:
http://foro.elhacker.net/php/pequenos_trucos_en_php-t152467.0.html

Función hecha por дٳŦ*

Código
  1. <?php
  2. //Ejemplo: send_mail("user@mail.com","cuerpo","asunto","demi@localhost","demi");
  3.  
  4. function send_mail($to, $body, $subject, $fromaddress, $fromname, $attachments=false)
  5. {
  6.  $eol="\r\n";
  7.  $mime_boundary=md5(time());
  8.  
  9.  # Common Headers
  10.  $headers .= "From: ".$fromname."<".$fromaddress.">".$eol;
  11.  $headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
  12.  $headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;    // these two to set reply address
  13.  $headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
  14.  $headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two to help avoid spam-filters
  15.  
  16.  # Boundry for marking the split & Multitype Headers
  17.  $headers .= 'MIME-Version: 1.0'.$eol.$eol;
  18.  $headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"".$eol.$eol;
  19.  
  20.  # Open the first part of the mail
  21.  $msg = "--".$mime_boundary.$eol;
  22.  
  23.  $htmlalt_mime_boundary = $mime_boundary."_htmlalt"; //we must define a different MIME boundary for this section
  24.  # Setup for text OR html -
  25.  $msg .= "Content-Type: multipart/alternative; boundary=\"".$htmlalt_mime_boundary."\"".$eol.$eol;
  26.  
  27.  # Text Version
  28.  $msg .= "--".$htmlalt_mime_boundary.$eol;
  29.  $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
  30.  $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  31.  $msg .= strip_tags(str_replace("<br>", "\n", substr($body, (strpos($body, "<body>")+6)))).$eol.$eol;
  32.  
  33.  # HTML Version
  34.  $msg .= "--".$htmlalt_mime_boundary.$eol;
  35.  $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
  36.  $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  37.  $msg .= $body.$eol.$eol;
  38.  
  39.  //close the html/plain text alternate portion
  40.  $msg .= "--".$htmlalt_mime_boundary."--".$eol.$eol;
  41.  
  42.  if ($attachments !== false)
  43.  {
  44.    for($i=0; $i < count($attachments); $i++)
  45.    {
  46.      if (is_file($attachments[$i]["file"]))
  47.      {  
  48.        # File for Attachment
  49.        $file_name = substr($attachments[$i]["file"], (strrpos($attachments[$i]["file"], "/")+1));
  50.  
  51.        $handle=fopen($attachments[$i]["file"], 'rb');
  52.        $f_contents=fread($handle, filesize($attachments[$i]["file"]));
  53.        $f_contents=chunk_split(base64_encode($f_contents));    //Encode The Data For Transition using base64_encode();
  54.        $f_type=filetype($attachments[$i]["file"]);
  55.        fclose($handle);
  56.  
  57.        # Attachment
  58.        $msg .= "--".$mime_boundary.$eol;
  59.        $msg .= "Content-Type: ".$attachments[$i]["content_type"]."; name=\"".$file_name."\"".$eol;  // sometimes i have to send MS Word, use 'msword' instead of 'pdf'
  60.        $msg .= "Content-Transfer-Encoding: base64".$eol;
  61.        $msg .= "Content-Description: ".$file_name.$eol;
  62.        $msg .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
  63.        $msg .= $f_contents.$eol.$eol;
  64.      }
  65.    }
  66.  }
  67.  
  68.  # Finished
  69.  $msg .= "--".$mime_boundary."--".$eol.$eol;  // finish with two eol's for better security. see Injection.
  70.  
  71.  # SEND THE EMAIL
  72.  ini_set(sendmail_from,$fromaddress);  // the INI lines are to force the From Address to be used !
  73.  $mail_sent = mail($to, $subject, $msg, $headers);
  74.  
  75.  ini_restore(sendmail_from);
  76.  
  77.  return $mail_sent;
  78. }
  79. ?>


En línea



Yo le enseñe a Kayser a usar objetos en ASM
дٳŦ٭
GNU/Linux Infrastructure Specialist
Ex-Staff
*
Desconectado Desconectado

Mensajes: 5.110


Ver Perfil WWW
Re: Problemas con envio de email en php
« Respuesta #2 en: 4 Abril 2009, 07:35 am »

No sale, se va al spam, que sucede?, para usar la funcion mail() necesitas un relay... prueba con sockets, usando phpmailer. Suerte
En línea

carnicero666

Desconectado Desconectado

Mensajes: 28


Ver Perfil
Envio de mail?
« Respuesta #3 en: 7 Abril 2009, 01:38 am »

hola a todos, estoy enviando un mail com php, y tengo un problema, el mensaje del mail no llega solo el titulo, si alguie me puede decir donde esta mi error, aqui dejo el codigo


<?php

$destino = "yo@server.com";
$direccion = $_GET['direccion'];
$msg = $_GET['nombre'];
$msg = $_GET['mail'];
$msg = $_GET['telefono'];
//Enviamos el mail
mail ($destino, "Registro de clases ",$msg);

//Le decimos al user que su mail ha sido enviado con exito
echo "Tu mensaje ha sido enviado con exito ha:  $destino !!";
?>

 
En línea

Nakp
casi es
Ex-Staff
*
Desconectado Desconectado

Mensajes: 6.336

he vuelto :)


Ver Perfil WWW
Re: Envio de mail?
« Respuesta #4 en: 7 Abril 2009, 21:38 pm »

te importaría postear todo en el mismo tema? no crees uno nuevo para responder :¬¬

@alf: borra este post y combina el tema con este por favor :xD
https://foro.elhacker.net/php/problemas_con_envio_de_email_en_php-t250752.0.html
En línea

Ojo por ojo, y el mundo acabará ciego.
дٳŦ٭
GNU/Linux Infrastructure Specialist
Ex-Staff
*
Desconectado Desconectado

Mensajes: 5.110


Ver Perfil WWW
Re: Envio de mail?
« Respuesta #5 en: 7 Abril 2009, 21:51 pm »

te importaría postear todo en el mismo tema? no crees uno nuevo para responder :¬¬

@alf: borra este post y combina el tema con este por favor :xD
https://foro.elhacker.net/php/problemas_con_envio_de_email_en_php-t250752.0.html

Deal.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines