Buon giorno, ho letto questo Post
" http://forum.html.it/forum/showthrea...hreadid=513009 "
molto interessante su come allegare un file nell'email, quello che voglio capire però è come mai, seguendo le indicazioni non mi allega nulla...
La stringa o la path che indica il file da allegare, la invio tramite post nella pagina dove c'è l'invio effettivo della mail.
codice:
$titolo="file.pdf"; /*Inserire il nome che si vuole dare all'allegato*/
$f=$_POST['txtAllegato'];
/*Inserire l'indirizzo del file che si vuole inviare come allegato*/
$filetype="application/pdf"; /*Inserire il formato MIME del file da allegare*/
//--CODICE NECESSARIO PER ALLEGARE UN FILE ALLA MAIL---//
$body_top = "--Message-Boundary\n";
$body_top .= "Content-type: text/html; charset=iso-8859-1\n";
$body_top .= "Content-transfer-encoding: 7BIT\n";
$body_top .= "Content-description: Mail message body\n\n";
$msg_body = $body_top . $mess;
$filez = fopen($f, "r");
$contents = fread($filez, filesize($f));
$encoded_attach = chunk_split(base64_encode($contents));
fclose($filez);
$msg_body .= "\n\n--Message-Boundary\n";
$msg_body .= "Content-type: $filetype; name=\"$titolo\"\n";
$msg_body .= "Content-Transfer-Encoding: BASE64\n";
$msg_body .= "Content-disposition: attachment; filename=\"$titolo\"\n\n";
$msg_body .= "$encoded_attach\n";
$msg_body .= "--Message-Boundary--\n";
// IL SOGGETTO DELLA MAIL
$subject = "Richiesta Pronto Intervento proveniente da " . $txtDa;
$body = "Contenuto del modulo:\n\n";
$body .= "Da: " . $txtDa . "\n";
$body .= "Protocollo N: " . $txtProtocolloInvio . "\n";
//etc etc...
// INTESTAZIONI SUPPLEMENTARI
$headers = "From: RICHIESTA INTERVENTO";
if(@mail($Servizi_Sezioni,$subject, $body, $headers, $msg_body)) {
echo "
<font class=\"max\">
La mail di Richiesta Intervento è stata inoltrata al servizio" . $Servizi_Sezioni .
"con successo
</font>" ;
}
else {
echo "Impossibile inviare la Mail - Riprovare più tardi";
}
Mi dite per favore dove sbaglio?Grazie mille