Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    1,150

    [PHP] invio email con pdf (non funziona)

    Ciao a tutti,
    so che il problema e' semplice, ma tutte le risorse che ho trovato non mi hanno risolto il problema dell'invio di un file .pdf.

    Probabilmente e' la fretta, ma non riesco a risolvere.
    Vi posto il codice, che fa parte di una classe php e quello che ho a video.
    Spero di trovare una soluzione.

    Grazie

    ps. considerate che la mail arriva, con la parte del testo formattata correttamente in HTML. Mentre il file .pdf arriva come codice, cosi' come lo mostro nella ultima parte del post

    codice:
                $random_hash = md5(date('r', time())); 
    
                //define the headers we want passed. Note that they are separated with \r\n
                $headers = "From:". $this->emailFrom."\r\n Reply-To: ".$this->emailReplay."";
    
    	    $mime_boundary = "==Multipart_Boundary_x{$random_hash}x";
    	    $headers .= "\nMIME-Version: 1.0\n" .
    	                "Content-Type: multipart/mixed;\n" .
    	                " boundary=\"{$mime_boundary}\"";
    
    	    $bodyTop .= "This is a multi-part message in MIME format.\n\n" .
    	                "--{$mime_boundary}\n" .
    	                "Content-Type:text/html; charset=\"iso-8859-1\"\n" .
    	                "Content-Transfer-Encoding: 7bit\n\n" .
    	    $bodyTop .= "\n\n";
    
    	    // Insert the email text (HTML)
    	    $bodyMsg = $bodyTop.$this->content;
    
        	    // Insert the email attach
                $bodyMsg .= "--$mime_boundary\n" .
                            "Content-Type: $this->mime;\n" .
                            "name=\"$this->file\"\n";
                            "Content-Transfer-Encoding: base64\n\n";
    	    $bodyMsg .= "$this->encodedAttach\n";
    	    $bodyMsg .= "--$mime_boundary--\n";
    E la variabile bodyMsg e' cosi' popolata (taglio volutamente la parte del pdf)
    codice:
    This is a multi-part message in MIME format. --==Multipart_Boundary_x5056938b9ad40ab9f5416e82bda8edeax Content-Type:text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit
    Texto html emailxxx
    --==Multipart_Boundary_x5056938b9ad40ab9f5416e82bda8edeax Content-Type: application/pdf; name="file.pdf" JVBERi0xLjQNJeLjz9MNCjEwIDAgb2JqDTw8L0xpbmVhcml6ZWQgMS9MIDU3NTgzOC9PIDEyL0Ug NTcxMjUzL04gMS9UIDU3NTUzNC9IIFsgNDk0IDE3NV0+P
    ..........
    .........
    DExAVhuI5J8DIhl7wSQ3UPaHxSWwLAMjiGT6DyIZGQACDAC05gYbDQplbmRzdHJlYW0NZW5kb2Jq DXN0YXJ0eHJlZg0KMTE2DQolJUVPRg0K --==Multipart_Boundary_x5056938b9ad40ab9f5416e82bda8edeax--

  2. #2
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    1,150
    Ho provato modificando cosi', ma non risolvo lo stesso.

    codice:
                $bodyMsg .= "--{$mime_boundary}\n" .
                            "Content-Type: $this->mime;\n" .
                            "name=\"{$this->file}\"\n".
                            "Content-Transfer-Encoding: BASE64\n\n".
                            "Content-disposition: attachment; filename=\"{$this->file}\"\n\n";
    	    $bodyMsg .= "{$this->encodedAttach}\n";
    	    $bodyMsg .= "--{$mime_boundary}--\n";
    Qualcuno puo' darmi qualche suggerimento?

    Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.