Salve,
ho la necessità di inviare una notifica con allegato ma con il seguente codice non viene visualizzato il mittente.
Provo il tutto su altervista ed alla voce mittente ho il seguente indirizzo apache@ns51.altervista.org.
Questo è il mio codice.
Codice PHP:
<?php
$headers = 'From: "MIONOME"<io@io.it> \r\n';
$headers = "Reply-to: INDIRIZZOMAIL\r\n";
$destinatario001 = <INDIRIZZOMAIL>".",";
$oggetto = " Notifica ";
$messaggio = "TESTO MESSAGGIO";
//Variabili allegato
$allegato = $_FILES['allegato']['tmp_name'];
$allegato_type = $_FILES['allegato']['type'];
$allegato_name = $_FILES['allegato']['name'];
if (is_uploaded_file($allegato))
{
$file = fopen($allegato,'rb');
$data = fread($file, filesize($allegato));
fclose($file);
$data = chunk_split (base64_encode($data));
//Separatore testo/allegato
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
//Intestazioni allegato
$headers .= "\nMIME-version: 1.0\n";
$headers .= "Content-Type: multipart/mixed;\n";
$headers .= "boundary=\"{$mime_boundary}\"";
//Msg Mime/multi-part
$msg .= "Message MIME multi-part.\n\n";
//Separatore
$msg .= "--{$mime_boundary}\n";
//Parte testuale
$msg .= "Content-Type: text/plain; charset=\iso-8859-1\"|n";
$msg .= "Content-Transfer-Encoding: 7bit\n\n";
$msg .= $messaggio . "\n\n";
//Separatore
$msg .= "--{$mime_boundary}\n";
$msg .= "Content-Disposition: attachment;\n";
$msg .= "filename=\"{$allegato_name}\"\n";
$msg .= "Content-Transfer-Encoding: base64\n\n";
$msg .= $data ."\n\n";
//Separatore chiusura
$msg .= "--{$mime_boundary}--\n";
}
else
{
$msg = $messaggio;
}
// Invio la mail
if (mail($destinatario001, $oggetto, $msg, $headers))
{
echo "
Mail inviata con successo!</p>";
}else{
echo "
Errore!</p>";
}
?>