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--