Ok I've read through all these forums, and php.net but have not been able to solve this problem. I'm trying to send an image with the mail function but all I've been getting is html text. Can someone point me in the right direction.

Here's what I have:

// Generate a boundary string 
$semi_rand = md5(time());  
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // Base64 encode the file data $data = chunk_split(base64_encode($data)); $logo= "--{$mime_boundary}\n";
$logo.="Content-Type: image/gif;\n"; $logo.="name='maillogo.gif'\n"; //Logo image $logo.="Content-Disposition: inline \n"; $logo.="Content-Transfer-Encoding: base64\n\n"; $logo.=$data . "\n\n";
$logo.="--{$mime_boundary}--\n"; $from="\"$from_name\" <$from_mail>"; $headers="\nMIME-Version: 1.0\n"; $headers.="Content-Type: multipart/mixed; charset='iso-8859-1'\n"; $headers.="From: $from\nX-Mailer: System33r"; $headers.=" boundary=\"{$mime_boundary}\""; $subject="$from_name recommends this website"; $body=$logo; $body.="Content-Type: text/plain; charset=\"iso-8859-1\"\n"; $body.="Content-Transfer-Encoding: 7bit\n\n"; $body.="Hello $to_name,\n <b>$from_name</b> requested that we send you this e-mail including this personal message:<br>"; $body.="<font color=$main>$message\n</font>"; $body.="<br>-----<br>\n"; $body.=$signature; $body.="--{$mime_boundary}\n"; mail($to_mail,$subject,$body,$headers); Header ("Location: $thank");

    Look at my example; I am able to get image via email, check my script there....
    I am also on SAFE MODE server so I can only use upto 4 parameters in mail()

    my example

      I took a look at Bajer's example and made some adjustments, everything seems fine exept now I'm getting an image placeholder instead of the actual image. Am I missing something here???

      $logo="<img src='maillogo.gif' width'152' height='31' border='0'>\n";  //Logo image
      
      $subject="$from_name recommends the website";
      
      $from="\"$from_name\" <$from_mail>";
      
      $headers  = "MIME-Version: 1.0\n";
      $headers.="Content-Type: text/html; charset=iso-8859-1\n";
      $headers .= "Content-Transfer-Encoding: 8bit;\n";
      $headers.="From: $from\nX-Mailer: System33r\n";
      
      $body="<html><head></head><body><table><tr><td>";
      $body.=$logo;
      $body.="Hello $to_name,<br> <b>$from_name</b>  requested that we send you this e-mail including this personal message:<br>"; 
      $body.="<font color=$main>$message\n</font>";
      $body.="<br>-----<br>\n";
      $body.=$signature;
      $body.="</td></tr></table></body></html>"; 
      
      mail($to_mail,$subject,$body,$headers);
      Header ("Location: $thank");
      

        $logo="<img src='maillogo.gif' width'152' height='31' border='0'>\n"; //Logo image

        double check if the file is actually in the same directory as your php file, i actually use:

        $logo="<img src='http://www.spam.com/pictures/maillogo.gif' width'152' height='31' border='0'>\n"; //Logo image

        because onces email comes; it also needs to know the location of your file....that's my understanding behind this.....try it out...

          Bajer, You solved my problem! You're awesome. My file was in the same directory as the php emailer file, but for some reason it couldn't find it. So using http://www..... worked out.

          Thanks again.

            glad, that I could be useful !!!

              Hey tripwire8....do you mind marking this thread resolved???

              Thanks,,
              r2

                10 months later

                Hi
                For source you have to specify something which is available globally i.e on the net.
                What if I want to send an image stored on my local drive as an inline image??

                  Write a Reply...