Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/08/2005, 02:01
Avatar de TCL_ZIP
TCL_ZIP
 
Fecha de Ingreso: noviembre-2003
Ubicación: Esporles, Mallorca, España
Mensajes: 690
Antigüedad: 20 años, 5 meses
Puntos: 4
Funcion enviar mail con datos adjuntos

he echo un script que teoricamente es para conseguir enviar un e-mail en formato html y un archivo adjunto, todo me funciona bien escepto el archivo adjunto, pero no me da ningun error, please una ayudita


Código PHP:
<?
function enviamail($destinatario$remite$titulo$message$adjunto){
$UN_SALTO="\r\n";
$DOS_SALTOS="\r\n\r\n";


$mensaje="<html><head></head><body bgcolor=\"#0000ff\">";
$mensaje .="<font face=\"Arial\" size=6>".$message." </font>";
$mensaje .="</body></html>";

$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: ".$_FILES["adjunto"][type]."; name=".$_FILES["adjunto"][name].".$UN_SALTO;  
$adj1 .="
Content-Dispositioninlinefilename="".$_FILES["adjunto"][name]."\"".$UN_SALTO;
$adj1 .="Content-Transfer-Encoding: base64".$DOS_SALTOS

echo 
"tipo:".$_FILES["adjunto"][type]."<br>" ;
      
# lectura  del fichero adjunto  

           
$buff $adjunto
 
      
# codificación del fichero adjunto  
$adj1 .=chunk_split(base64_encode($buff)); 

      
# Separador de partes

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




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


  
$mensaje=$texto.$adj1;


 
// envio del mensaje 

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