ERLEDIGT
NEIN
NEIN
ANTWORTEN
2
2
ZUGRIFFE
2196
2196
EMPFEHLEN
-
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:
Code :1 2 3 4
--=_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-Code:$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
-
Probier mal Folgendes:
PHP-Code:$ImageLocation ="./images/hintergrund.jpg";
$ImgName = "hintergrund.jpg";
$CID = md5(uniqid(rand()));
$boundary = md5(uniqid(rand()));
// Create the Headers
$headers = "From: xxx\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; 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.= imap_8bit("
<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
$EmailBody.= "Content-Type: image/jpeg\r\n";
$EmailBody.= "Content-ID: <$CID.$ImgName>\r\n";
$EmailBody.= "Content-Transfer-Encoding: base64\r\n";
$EmailBody.= "Content-Disposition: inline; filename=\"$ImgName\"\r\n\r\n";
$EmailBody.= chunk_split(base64_encode(file_get_contents($ImageLocation)));
$EmailBody.= "\r\n--".$boundary."--"; // Mark the end of the Image Part
Markus Wulftange
-
Hallo,
Wenn ich es richtig gesehen habe, hast Du nur diesen Teil "imap_8bit" eingefuegt, das hat aber leider nichts gebracht.
Stimmen denn diese Teile?
$EmailBody.= "--".$boundary."\r\n";
Gruss
Ähnliche Themen
-
HTML Seiten automatisch generieren
Von liz78x im Forum PHPAntworten: 36Letzter Beitrag: 20.04.10, 17:27 -
Formular zum generieren eines HTML Codes
Von PC Freak im Forum Stellenangebote (entgeltlich)Antworten: 3Letzter Beitrag: 02.08.09, 18:09 -
email mit bild per php generieren.
Von macropode im Forum PHPAntworten: 1Letzter Beitrag: 19.12.07, 19:07 -
HTML Seiten generieren
Von fireblader im Forum PHPAntworten: 4Letzter Beitrag: 30.10.04, 12:06 -
HTML Tabellen generieren
Von andyK im Forum PHPAntworten: 3Letzter Beitrag: 07.11.03, 14:25





Zitieren
Login






[PHP][Snippet] Array zu XML konvertieren