Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/01/2010, 06:16
davicito
 
Fecha de Ingreso: marzo-2009
Mensajes: 480
Antigüedad: 15 años
Puntos: 1
no me funciona mail php

Hola, no entiendi poruqe no me funciona :S.
Esta bien configurado el PHP.ini

este si me funciona:
Código PHP:
<? 
if (!$_POST){ 
?> 
<form action="2.php" method=post> 
Nombre: <input type=text name="nombre" size=16> 
<br> 
Email: <input type=text name="email" size=16> 
<br> 
Comentarios: <textarea name="coment" cols=32 rows=6></textarea> 
<br> 
<input type=submit value="Enviar"> 
</form> 
<? 
}else{ 
    
//Estoy recibiendo el formulario, compongo el cuerpo 
    
$cuerpo "Formulario enviado\n"
    
$cuerpo .= "Nombre: " $_POST["nombre"] . "\n"
    
$cuerpo .= "Email: " $_POST["email"] . "\n"
    
$cuerpo .= "Comentarios: " $_POST["coment"] . "\n";
    
$cuerpo .="<font face=\"Arial\" size=6>Prueba HTML </font>";
    
//mando el correo... 
    
mail("[email protected]","Formulario recibido",$cuerpo); 

    
//doy las gracias por el envío 
    
echo "Gracias por rellenar el formulario. Se ha enviado correctamente."

?>
este no em funciona: (¿Porque? :S )
Código PHP:
<?
$UN_SALTO
="\r\n";
$DOS_SALTOS="\r\n\r\n";

$destinatario="[email protected]";
$titulo="Mensaje con dos fichero adjuntos";
$mensaje="<html><head></head>
<body style=\"font-size:15px\">"
;
$mensaje .="<img align=left src=\"inicio.jpg\"><br>agiahgiashgasighasoighasgoihoih";
$mensaje .="</body></html>";
//$responder="[email protected]";
$remite="[email protected]";
$remitente="Juan el del molin te envia un ficherín";

$separador "_separador_de_trozos_".md5 (uniqid (rand())); 
  
$cabecera "Date: ".date("l j F Y, G:i").$UN_SALTO
$cabecera .= "MIME-Version: 1.0".$UN_SALTO
$cabecera .= "From: ".$remitente."<".$remite.">".$UN_SALTO;
$cabecera .= "Return-path: "$remite.$UN_SALTO;
$cabecera .= "Reply-To: ".$remite.$UN_SALTO;
$cabecera .="X-Mailer: PHP/"phpversion().$UN_SALTO;
$cabecera .= "Content-Type: multipart/mixed;".$UN_SALTO
$cabecera .= " boundary=$separador".$DOS_SALTOS

// Parte primera -Mensaje en formato HTML 
      # Separador inicial
$texto ="--$separador".$UN_SALTO
      
# Encabezado parcial
$texto .="Content-Type: text/html; charset=\"ISO-8859-1\"".$UN_SALTO
$texto .="Content-Transfer-Encoding: 7bit".$DOS_SALTOS
      
# Contenido de esta parte del mensaje
  
$texto .= $mensaje;
 
      
# Separador de partes

$adj1 $UN_SALTO."--$separador".$UN_SALTO

// Parte segunda -Fichero adjunto nº 1  ------------------------------------------------------------------

      # Encabezado parcial
$adj1 .="Content-Type: image/jpeg; name=\"inicio.jpg\"".$UN_SALTO;  
$adj1 .="Content-Disposition: inline; filename=\"inicio.jpg\"".$UN_SALTO;
$adj1 .="Content-Transfer-Encoding: base64".$DOS_SALTOS

      
# lectura  del fichero adjunto  
      
$fp fopen("inicio.jpg""r"); 
           
$buff fread($fpfilesize("inicio.jpg")); 
       
fclose($fp); 
      
# codificación del fichero adjunto  
$adj1 .=chunk_split(base64_encode($buff)); 

// FINAL PARTE 1 -----------------------------------------------

// Unión de las diferentes partes para crear
   // el cuerpo del mensaje


  
$mensaje=$texto.$adj1;

 
// envio del mensaje 

  
if( mail($destinatario$titulo$mensaje,$cabecera)){
    echo 
"mensaje enviado";
}
?>