Hi there,
I'm trying to build a php-routine that sends an email with an attachment. I seem to be missing something, because the email is sent without attachment, with all contents in the emailbody.
This is the email:
Bestelling 1108247068366
Bestelling voor Plaza33 - Besteld op 12.02.2005........
.....Opmerkingen:
melding.
This is the attachtment:
<!DOCTYPE LV_ELECTRONIC_ORDER> ==== ENCODED ORDER - BEGIN ==== OV=1<~>..........................
melding.
Informatie bij betaling:
Geen
==== ENCODED ORDER - END ====
and this is how I receive the mail:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=" ==Multipart_Boundary_xffbb398b14c6197b07ba8c18e8d3
a5bax"
This is a multi-part message in MIME format.
-- ==Multipart_Boundary_xffbb398b14c6197b07ba8c18e8d3
a5bax
Content-Type:text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7BIT
Bestelling 1108248155553
Bestelling voor Plaza33 - Besteld op 12.02.2005...............Opmerkingen:
melding.
-- ==Multipart_Boundary_xffbb398b14c6197b07ba8c18e8d3
a5bax
Content-Type: application/octet-stream;charset=US-ASCII name=order-1108248155553.lce
Content-Transfer-Encoding: 7BIT
Content-Disposition: attachment; filename=order-1108248155553.lce <!DOCTYPE LV_ELECTRONIC_ORDER> ==== ENCODED ORDER - BEGIN ==== OV=1<~>OSV=1<................melding.
Informatie bij betaling:
Geen
==== ENCODED ORDER - END ====
-- ==Multipart_Boundary_xffbb398b14c6197b07ba8c18e8d3
a5bax--
And finaly, this is the code I use:
<?PHP
$from = $_REQUEST['From'];
$to = $_REQUEST['To'];
$subject = $_REQUEST['Subject'];
$subjectmailclient = $_REQUEST['SubjectMailClient'];
$message = $_REQUEST['Message'];
$attachment = $_REQUEST['Attachment'];
$orderid = $_REQUEST['OrderID'];
$redirect = $_REQUEST['redirect'];
$message1=$message;
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers = "From: ".$to." <".$to.">\n";
$headers .= "\nMIME-Version: 1.0\n"
. "Content-Type: multipart/mixed;\n"
. " boundary=\"{$mime_boundary}\"";
$email_message = "This is a multi-part message in MIME format.\n\n"
. "--{$mime_boundary}\n"
. "Content-Type:text/plain; charset=US-ASCII\n"
. "Content-Transfer-Encoding: 7BIT\n\n"
. $message1 . "\n\n";
$data = $attachment;
$email_message .= "--{$mime_boundary}\n"
. "Content-Type: application/octet-stream;"
. " name=order-".$orderid.".lce\n"
. "Content-Transfer-Encoding: 7BIT\n\n"
. "Content-Disposition: attachment;"
. " filename=order-".$orderid.".lce\n"
. $data
. "\n\n" ."--{$mime_boundary}--\n";
mail("$from", "$subject",
"$email_message",
"$headers");
?>
Can anyone tell me what I am overlooking?
Thanks, Frank.