Hallo,
Ich versuche eine HTML-Email zu generieren, die eine Tabelle mit einem Hintergrundbild enthaelt. Leider wird das Bild nicht angehaengt, sondern unten in der Mail ausgegeben:
Ich sehe meinen Fehler einfach nicht und hoffe daher, dass jemand eine Idee hat. Ich tippe mal darauf das ich irgendetwas mit dem $boundary verkehrt mache, aber was? Ich habe alles moegliche ausprobiert, aber es will nicht klappen. Freue mich ueber jeden Tip und ich hoffe das dies das Richtige Forum ist und nicht zu HTML statt PHP gehoert.
Vielen Dank im Voraus fuer Eure Hilfe.
Gruss Bicko
Ich versuche eine HTML-Email zu generieren, die eine Tabelle mit einem Hintergrundbild enthaelt. Leider wird das Bild nicht angehaengt, sondern unten in der Mail ausgegeben:
Code:
--=_XXXboundaryXXX Content-Type: image/jpeg Content-ID:
Content-Transfer-Encoding:base64 Content-Disposition: inline;
filename="hintergrund.jpg" /9j/4 AAQSkZJRgABAgAAZABkAAD
/7AARRHVja3kAAQAEAAAAZAAA/+4ADkFkb2JlAGTAAAA.....
Ich sehe meinen Fehler einfach nicht und hoffe daher, dass jemand eine Idee hat. Ich tippe mal darauf das ich irgendetwas mit dem $boundary verkehrt mache, aber was? Ich habe alles moegliche ausprobiert, aber es will nicht klappen. Freue mich ueber jeden Tip und ich hoffe das dies das Richtige Forum ist und nicht zu HTML statt PHP gehoert.
PHP:
$ImageLocation ="./images/hintergrund.jpg";
$ImgName = "hintergrund.jpg";
$CID = md5(uniqid (rand(), 1));
$boundary = "=_XXXboundaryXXX";
// Create the Headers
$headers = "From: xxx\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers.= "Content-Type: multipart/mixed; ";
$headers.= "boundary=\"$boundary\";\r\n";
$EmailBody = "--".$boundary."\r\n"; // Mark the end of the header
// Write the Header for the HTML Part
$EmailBody.= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
// After the last Header insert 2 Line Breaks
$EmailBody.= "Content-Transfer-Encoding: quoted-printable\r\n\r\n";
$EmailBody.= "
<html>
<head>
<title>xxx</title>
</head>
<body>
<table border=\"0\" width=\"700\" height=\"520\">
<tr>
<td background=\"cid:$CID.$ImgName\">
<table width=\"700\" height=\"520\" border=\"0\">
<tr>
<td colspan=\"2\" height=\"180\"></td>
</tr>
<tr>
<td width=\"200\" height=\"320\"></td><td valign=\"top\">
<h5>Hallo</h5>
<p>blah blah</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
";
$EmailBody.= "--".$boundary."\r\n\r\n"; // Mark the end of the html part
// Bild anhaengen
$fp = fopen ($ImageLocation, "rb");
$str = fread ($fp, filesize ($ImageLocation));
$data = chunk_split(base64_encode($str));
$content.= "Content-Type: image/jpeg\r\n";
$content.= "Content-ID: <$CID.$ImgName>\r\n";
$content.= "Content-Transfer-Encoding: base64\r\n";
$content.= "Content-Disposition: inline; filename=\"$ImgName\"\r\n";
$content.= $data;
$EmailBody.= $content;
$EmailBody.= "--".$boundary."--\r\n\r\n"; // Mark the end of the Image Part
Vielen Dank im Voraus fuer Eure Hilfe.
Gruss Bicko