• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 512
  • Last Modified:

PHP - mail() with inline image?

Hello,

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:

<?
session_start();
require_once('includes/inc_values.php');
require_once('includes/inc_connection.php');

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

$arraylengte = count($producten_ids);

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



error_reporting(E_ALL);
$headers = "From: test@test.nl\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("test@test.nl", "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
0
php-webdesign
Asked:
php-webdesign
1 Solution
 
hernst42Commented:
Use phpmailer.sf.net for this.

It allows easy attachment of inline-images
For a example see http://phpmailer.sourceforge.net/extending.html

So you don't need to reinvent the wheel
0
 
php-webdesignAuthor Commented:
thank you m8!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now