php-webdesign
asked on
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.ph p');
require_once('includes/inc _connectio n.php');
if(!empty($_COOKIE[COOKIE] )){
list($name, $adres, $zipcode, $location, $telephone, $email, $paymethod, $agree) = split("!", $_COOKIE[COOKIE]);
}
if(!empty($_SESSION['produ cten_shop' ])){
$producten_ids = substr($_SESSION['producte n_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( $htmlversi on));
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
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
require_once('includes/inc
if(!empty($_COOKIE[COOKIE]
list($name, $adres, $zipcode, $location, $telephone, $email, $paymethod, $agree) = split("!", $_COOKIE[COOKIE]);
}
if(!empty($_SESSION['produ
$producten_ids = substr($_SESSION['producte
$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
$headers .= chunk_split(base64_encode(
if(mail("test@test.nl", "Thanks for your order!", "", $headers)){
$message = "goed";
} else {
$message = "fout";
}
?>
$_COOKIE[COOKIE] and $_SESSION['producten_shop'
So can anybody help me with the inline images??
thanks, Mike
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER