Foros del Web » Programando para Internet » PHP »

Problema al enviar fichero adjunto con PEAR

Estas en el tema de Problema al enviar fichero adjunto con PEAR en el foro de PHP en Foros del Web. Buenas, estoy haciendo un pequeño programa en PHP que envia a una serie de usuarios registrados un email con estadisticas en excel. El problema esta ...
  #1 (permalink)  
Antiguo 28/05/2008, 06:11
 
Fecha de Ingreso: mayo-2008
Mensajes: 3
Antigüedad: 15 años, 10 meses
Puntos: 0
Problema al enviar fichero adjunto con PEAR

Buenas,
estoy haciendo un pequeño programa en PHP que envia a una serie de usuarios registrados un email con estadisticas en excel.

El problema esta en que cuando estos usuarios reciben el mail con el excel, se encuentran esto:

ZD48dGQ+MDwvdGQ+PHRkPjA8L3RkPjx0ZD4wPC90ZD48dGQ+MD wvdGQ+PHRkPjA8L3RkPjx0ZD4w
PC90ZD48dGQ+MDwvdGQ+PHRkPjA8L3RkPjx0ZD4wPC90ZD48dG Q+MDwvdGQ+PHRkPjA8L3RkPjx0
ZD4wPC90ZD48dGQ+MDwvdGQ+PHRkPjA8L3RkPjx0ZD4yPC90ZD 48dGQ+MDwvdGQ+PC90cj4KPHRy
Pjx0ZCBhbGlnbj0nbGVmdCc+U2Vuc2UgY2VudHJlPC90ZD48dG Q+MjwvdGQ+PHRkPjU8L3RkPjx0
ZD4xPC90ZD48dGQ+MDwvdGQ+PHRkPjA8L3RkPjx0ZD4wPC90ZD 48dGQ+MDwvdGQ+PHRkPjA8L3Rk
Pjx0ZD4wPC90ZD48dGQ+MDwvdGQ+PHRkPjE8L3RkPjx0ZD4wPC 90ZD48dGQ+MDwvdGQ+PHRkPjA8
L3RkPjx0ZD4wPC90ZD48dGQ+MDwvdGQ+PHRkPjA8L3RkPjx0ZD 4wPC90ZD48dGQ+MDwvdGQ+PHRk
PjA8L3RkPjx0ZD4wPC90ZD48dGQ+MDwvdGQ+PHRkPjA8L3RkPj x0ZD4wPC90ZD48dGQ+MTM8L3Rk
Pjx0ZD44PC90ZD48L3RyPgo8dHI+PHRkIGFsaWduPSdsZWZ0Jz 48Yj5Ub3RhbDwvYj48L3RkPjx0
ZD48Yj4xNDM8L2I+PC90ZD48dGQ+PGI+MTAwPC9iPjwvdGQ+PH RkPjxiPjI8L2I+PC90ZD48dGQ+
PGI+MDwvYj48L3RkPjx0ZD48Yj4wPC9iPjwvdGQ+PHRkPjxiPj A8L2I+PC90ZD48dGQ+PGI+MDwv
Yj48L3RkPjx0ZD48Yj4wPC9iPjwvdGQ+PHRkPjxiPjA8L2I+PC 90ZD48dGQ+PGI+MDwvYj48L3Rk
Pjx0ZD48Yj4xPC9iPjwvdGQ+PHRkPjxiPjA8L2I+PC90ZD48dG Q+PGI+MDwvYj48L3RkPjx0ZD48
Yj4wPC9iPjwvdGQ+PHRkPjxiPjA8L2I+PC90ZD48dGQ+PGI+MD wvYj48L3RkPjx0ZD48Yj4wPC9i
PjwvdGQ+PHRkPjxiPjA8L2I+PC90ZD48dGQ+PGI+MDwvYj48L3 RkPjx0ZD48Yj4wPC9iPjwvdGQ+
PHRkPjxiPjA8L2I+PC90ZD48dGQ+PGI+MDwvYj48L3RkPjx0ZD 48Yj4wPC9iPjwvdGQ+PHRkPjxi
PjA8L2I+PC90ZD48dGQ+PGI+MTU8L2I+PC90ZD48dGQ+PGI+ND IwPC9iPjwvdGQ+PC90cj48L1RB
QkxFPgg==
--=_3ecdf01038758f401775d038eadfc8fc--

texto que si pegamos en el bloc de notas y renombramos como xls, nos da el fichero excel, el problema es que el gestor de correo (Gmail, Lotus Notes) no interpretan bien el tipo y lo ponen como si fuera texto.

Aqui teneis el codigo a ver si alguien saber ver que estoy hacineod mal, un slaudo y mercy:

Código PHP:
    function EnviarcorreoFichero($from,$to,$subject,$body,$path,$type){
        
        
$host "soy.un.host";
        
$hdrs = array( 'From' => $from'To' => $to,'Subject' => $subject );
        
        
$mime = new Mail_mime("rn");
        
$mime->setTXTBody($body);
        
$mime->addAttachment($path,$type);
        
        
$hdrs $mime->headers($hdrs);
        
$body $mime->get();
        
        echo 
$hdrs;
        
        
$smtp Mail::factory('smtp', array ('host' => $host));
        
$mail $smtp->send($to$hdrs$body);

        return(
PEAR::isError($mail));
    } 
  #2 (permalink)  
Antiguo 28/05/2008, 09:41
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Problema al enviar fichero adjunto con PEAR

Hola TheSandman,

Al parecer te esta codificando mal el archivo PEAR, intenta hacerlo con la librería PHPMailer, he encontrado que funciona muy bien para enviar archivos adjuntos.

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:20.