ho fatto un passo avanti:
Codice PHP:
function sendEmailB2B() {
$header = "From: Sito <email.email.eu>\n";
$header .= "X-Mailer: Il nostro Php\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed;\n";
$header .= "Message-Boundary";
$messaggio = "--Message-Boundary\n";
$messaggio .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$messaggio .= "Content-Transfer-Encoding: 7bit\n\n";
$messaggio .= "<html><body>
TESTO</p>
<img src=\"cid:MiaImmagine123\" alt=\"mia immagine\"></p>
</body>
</html>\n\n";
$allegato = "../IMMAGINI/sfondo_email.jpg";
$file = fopen($allegato, 'rb');
$data = fread($file, filesize($allegato));
$data = chunk_split(base64_encode($data));
fclose($file);
$messaggio .= "Content-ID: <MiaImmagine123>\n";
$messaggio .= "Content-Type: image/jpeg\n";
$messaggio .= "Content-Transfer-Encoding: base64\n\n";
$messaggio .= "\n\n--Message-Boundary\n";
$messaggio .= "$data\n\n";
$messaggio .= "--Message-Boundary--\n";
$subject = "messaggio con immagine inline";
if (mail('maiemail@hotmail.it', $subject, $messaggio, $header)) {
echo '<h3 style="color:red;">Mail inviata correttamente
</h3>';
} else {
echo '<h3 style="color:red;">ERRORE!</h3>';
}
}
adesso la mail arriva però l'immagine nn si vede.
al suo posto si vede una roba del genere:
codice:
Message-Boundary
--Message-Boundary
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<html><body>
TESTO</p>
[img]cid:MiaImmagine123[/img]</p>
</body>
</html>
Content-ID: <MiaImmagine123>
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
--Message-Boundary
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcU
FhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgo
KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAHzAlgDASIA
AhEBAxEB/8QAHAAAAQUBAQEAAAAAAAAAAAAAAAMEBQYHAQII/8QAUhAAAgEDAwIEAwUGAwUFBAYL
AQIDAAQRBRIhMUEGEyJRYXGBBxQykaEVI0Kx0fBSweEkM1Ni8QgWcoKyQ3ODkhclNFRjdKKjwjU2
ZCaTlLPT/8QAGwEBAAMBAQEBAAAAAAAAAAAAAAECAwQFBgf/xAA1EQACAQIEBAMHBAMAAwEAAAAA
AQIDEQQSITETQXGRIlFSBRQyM2FysSNCYqEGJIHB0fDh/9oADAMBAAIRAxEAPwD52ooooAooooAo
...........