tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
2
ZUGRIFFE
2196
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    Bicko Bicko ist offline Mitglied Gold
    Registriert seit
    Sep 2003
    Beiträge
    160
    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 ($fpfilesize ($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
     

  2. #2
    Registriert seit
    Dec 2002
    Ort
    Trier
    Beiträge
    17.502
    Blog-Einträge
    10
    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

  3. #3
    Bicko Bicko ist offline Mitglied Gold
    Registriert seit
    Sep 2003
    Beiträge
    160
    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

  1. HTML Seiten automatisch generieren
    Von liz78x im Forum PHP
    Antworten: 36
    Letzter Beitrag: 20.04.10, 17:27
  2. Formular zum generieren eines HTML Codes
    Von PC Freak im Forum Stellenangebote (entgeltlich)
    Antworten: 3
    Letzter Beitrag: 02.08.09, 18:09
  3. email mit bild per php generieren.
    Von macropode im Forum PHP
    Antworten: 1
    Letzter Beitrag: 19.12.07, 19:07
  4. HTML Seiten generieren
    Von fireblader im Forum PHP
    Antworten: 4
    Letzter Beitrag: 30.10.04, 12:06
  5. HTML Tabellen generieren
    Von andyK im Forum PHP
    Antworten: 3
    Letzter Beitrag: 07.11.03, 14:25