#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    87
    Rep Power
    11

    need an example for embedding image using PEAR mail_mime


    I know what function to call, but I'm not following how to put in the variables. Here's the code:
    PHP Code:
    <?php
    include('Mail.php');
    include(
    'Mail/mime.php');
    $text 'Text version of email';
    $html '<html><body>HTML version of <b>email</b><img src="http://67.95.173.208/images/cust_ball.gif"><br/>';
    $html .='<font face="verdana" size="1">This can be used to <u>spice up</u> emails with extra goodies!</font></body></html>';
    $file 'images/cust_ball.gif';
    $crlf "\r\n";
    $hdrs = array(
            
    'From' => 'email@email.org',
            
    'Subject' => 'Test message'
            
    );
    $mime = new Mail_mime($crlf);
    $mime->addHTMLImage('images/cust_ball.gif''image/gif','images/cust_ball.gif');
    $mime->setTXTBody($text);
    $mime->setHTMLBody($html);
    $mime->addAttachment($file'image/gif');
    $body $mime->get();
    $hdrs $mime->headers($hdrs);
    $mail =& Mail::factory('mail');
    $mail->send('email@email.net'$hdrs$body);
    ?>
    The attachment works fine, the HTML mail works fine, but no image gets embedded. I've tried writing the '<img src>' tags into the $html, but to no avail. Any help would be appreciated!
    Last edited by jreider; March 27th, 2004 at 10:59 AM. Reason: corrections
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    1
    Rep Power
    0
    Hello there, I did it like this:

    PHP Code:
    <?php
    //include code...

    //in html only the filename
    $html '<html><body><img src="imagename.gif"></body></html>';
    $crlf "\r\n";
    $hdrs = array( 
            
    'From' => 'me@mine.org'
            
    'Subject' => 'Test message' 
            
    ); 

    $mime = new Mail_mime($crlf); 
    $mime->setHTMLBody($html); 
    //and here the filepath
    $mime->addHTMLImage("./images/imagename.gif""image/gif");
    $body $mime->get();
    $hdrs $mime->headers($hdsr);
    $mail->send('tome@mine.org'$hdrs$body);
    ?>
    I hope it helps, and if your Dutch, happy queensday!!!
    (and if your not, also)
    Last edited by stoor; April 26th, 2004 at 10:29 AM.

IMN logo majestic logo threadwatch logo seochat tools logo