Ciao ragazzi, io ho un problema nell'invio della mail in html.
Mi spiego meglio, qundo invio la mail da php in html la mail mi arriva a destinazione ma vuota con un allegato senza nome, che se lo apro con firefox è la pagina in html che dovrebbe arrivare!!!
Posto il codice perchè non riesco a capire prorpio dove sia l'errore
Codice:
// Invio mail di accesso
$int = 'MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: ****** <******@***>
Reply-to: ******@******.***
';
$int = $int.'X-Mailer: PHP/'.phpversion();
$int = $int.'Content-Transfer-Encoding: 8bit';
$boundary = '.::separatoreMsg::.';
$int = $int.'Content-Type: multipart/alternative;\n';
$int = $int.' boundary="'.$boundary.'"';
$msgTextAlternative = '
Testo semplice';
// inizia la prima parte del messaggio in testo puro
$msgText .= '--'.$boundary.'\n';
$msgText .= 'Content-Type: text/plain; charset="iso-8859-1"\n';
$msgText .= 'Content-Transfer-Encoding: 7bit\n\n';
$msgText .= $msgTextAlternative;
//$msgText = $msgTextAlternative;
// inizia la seconda parte del messaggio in formato html
$msgText .= '--'.$boundary.'\n';
$msgText .= 'Content-Type: text/html; charset="iso-8859-1"\n';
$msgText .= 'Content-Transfer-Encoding: 8bit\n\n';
$msgText .= '
<html>
<head>
<title>Titoli</title>
<style>
.int{
border-bottom:#000000 solid 1px;
font-weight:bold;
}
#dati{
background:#cacaca;
}
</style>
</head>
<body>
<h1>Titolo in Pagina</h1>
<p>test</p>
<table cellspacing=0><tbody>
<tr class=int>
<td>Cella</td>
</tr>
</tbody></table>
</body>
</html>';
// chiusura del messaggio con la stringa boundary
$msgText .= '--'.$boundary.'--\n';
$addressMsg = '******@******.******';
$titleMsg = 'TitoloMessaggio';
echo $msgText;
if( mail($addressMsg, $titleMsg, $msgText, $int) ) echo "e-mail inviata con successo!";
else echo "errore nell'invio dell'e-mail!";
Mi spiego meglio, qundo invio la mail da php in html la mail mi arriva a destinazione ma vuota con un allegato senza nome, che se lo apro con firefox è la pagina in html che dovrebbe arrivare!!!
Posto il codice perchè non riesco a capire prorpio dove sia l'errore
Codice:
// Invio mail di accesso
$int = 'MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: ****** <******@***>
Reply-to: ******@******.***
';
$int = $int.'X-Mailer: PHP/'.phpversion();
$int = $int.'Content-Transfer-Encoding: 8bit';
$boundary = '.::separatoreMsg::.';
$int = $int.'Content-Type: multipart/alternative;\n';
$int = $int.' boundary="'.$boundary.'"';
$msgTextAlternative = '
Testo semplice';
// inizia la prima parte del messaggio in testo puro
$msgText .= '--'.$boundary.'\n';
$msgText .= 'Content-Type: text/plain; charset="iso-8859-1"\n';
$msgText .= 'Content-Transfer-Encoding: 7bit\n\n';
$msgText .= $msgTextAlternative;
//$msgText = $msgTextAlternative;
// inizia la seconda parte del messaggio in formato html
$msgText .= '--'.$boundary.'\n';
$msgText .= 'Content-Type: text/html; charset="iso-8859-1"\n';
$msgText .= 'Content-Transfer-Encoding: 8bit\n\n';
$msgText .= '
<html>
<head>
<title>Titoli</title>
<style>
.int{
border-bottom:#000000 solid 1px;
font-weight:bold;
}
#dati{
background:#cacaca;
}
</style>
</head>
<body>
<h1>Titolo in Pagina</h1>
<p>test</p>
<table cellspacing=0><tbody>
<tr class=int>
<td>Cella</td>
</tr>
</tbody></table>
</body>
</html>';
// chiusura del messaggio con la stringa boundary
$msgText .= '--'.$boundary.'--\n';
$addressMsg = '******@******.******';
$titleMsg = 'TitoloMessaggio';
echo $msgText;
if( mail($addressMsg, $titleMsg, $msgText, $int) ) echo "e-mail inviata con successo!";
else echo "errore nell'invio dell'e-mail!";