PHP - mail() with inline image?


I am creating a webshop. and now i am going to send the email with the order.
BUT... it needs to be in HTML (no problem), and with inline images (you attach an image to the mail and this is displayed in the mail)

Does anybody know how this can be done??

the script i have:


      list($name, $adres, $zipcode, $location, $telephone, $email, $paymethod, $agree) = split("!", $_COOKIE[COOKIE]);
      $producten_ids = substr($_SESSION['producten_shop'], 0, -1);
      $producten_ids = explode("!", $producten_ids);
$htmlversion = ("
Your details:<br>
Naam:                  " . $name. "<br>
Adres:                  " . $adres . "<br>
Postcode:            " . $zipcode. "<br>
Plaats:                  " . $location. "<br>
Telefoon:            " . $telephone. "<br>
Email:                  " . $email . "<br>
Betaalmethode:            " . $paymethod. "<br>
Our details:<br>
Naam:                  " . NAME. "<br>
Adres:                  " . ADRES . "<br>
Postcode:            " . ZIPCODE. "<br>
Plaats:                  " . LOCATION. "<br>
Telefoon:            " . TELEPHONE. "<br>
Email:                  " . EMAIL . "<br>
Your order::<br>

$arraylengte = count($producten_ids);

for($i=0; $i < $arraylengte; $i++){
      $htmlversion .= "product id: " . $producten_ids[$i] . "<br>";

$headers = "From:\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$boundary = uniqid("SHOP");
$headers .= "Content-Type: multipart/alternative" .
   "; boundary = $boundary\r\n\r\n";
$headers .= "This is a MIME encoded message.\r\n\r\n";
$headers .= "--$boundary\r\n" .
   "Content-Type: text/html; charset=ISO-8859-1\r\n" .
   "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($htmlversion));
if(mail("", "Thanks for your order!", "", $headers)){
      $message = "goed";
} else {
      $message = "fout";


$_COOKIE[COOKIE] and $_SESSION['producten_shop'] are set in the previous page and contain the account details and products ordered. (all works perfect)

So can anybody help me with the inline images??

thanks, Mike
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use for this.

It allows easy attachment of inline-images
For a example see

So you don't need to reinvent the wheel

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
php-webdesignAuthor Commented:
thank you m8!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.