|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-01-20 11:28 UTC] adrian at sourceconsulting dot co dot za
$attachment['file_name'] = "a.doc";
$attachment['mime_type'] = "application/msword";
$attachment['description'] = "Request for On-Site Support";
$attachment['encoded_string'] = CMS_file_get_contents("files/rfoss.b64",1); //returns the base64 encoded file as a string
$headers .= "From: ".$strFromName." <$strFrom>\r\n";
$headers .= "Reply-To:$strReplyTo <$strReplyTo>\r\n";
$headers .= "X-Priority: $intPriority\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
$headers .= "Content-type: multipart/mixed;\r\n";
$headers .= "\t boundary=\"SIMS------8f08ef19c30c5ab8bec2cd1a99c3578e\"\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n\r\n This is a MIME encoded message\r\n\r\n";
$headers .= "--SIMS------8f08ef19c30c5ab8bec2cd1a99c3578e\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= base64_encode($strMessage)."\r\n\r\n\r\n\r\n";
$headers .= "--SIMS------8f08ef19c30c5ab8bec2cd1a99c3578e\r\n";
$headers .= "Content-Type: ".$attachment['mime_type']."; charset=iso-8859-1;\r\n";
$headers .= "\tname=".$attachment['file_name']."\r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n";
$headers .= "Content-Description: ".$attachment['description']."\r\n\r\n";
$headers .= chunk_split($attachment['encoded_string']."\r\n\r\n";
$headers .= "--SIMS------8f08ef19c30c5ab8bec2cd1a99c3578e--\r\n";
$bSent = mail($strTo, $strSubject,"", $headers);
The code shown works perfectly when sending small attachments.
If I try to send an attachment more than a few kbytes in size it causes apache to throw an error.
I have set php to use up to 20 mbytes of memory when executing a script in the hope that it was a buffer overflow but to no avail.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 15:00:02 2025 UTC |
<?php if($_POST['submit']) { $fullname=$_POST['fullname']; $relatedname=$_POST['relatedname']; $gender=$_POST['gender']; $approxage=$_POST['approxage']; $missingdate=$_POST['day']."/".$_POST['month']."/".$_POST['year']; $missinglocation=$_POST['missinglocation']; $address=$_POST['address']; $phone=$_POST['phone']; $languages=$_POST['languages']; $height=$_POST['feet']."feet ".$_POST['inches']."inches"; $hair=$_POST['hair']; $complexion=$_POST['complexion']; $mentalcondition=$_POST['mentalcondition']; $lastseen=$_POST['lastseen']; $to="swanand@pixelisolutions.com"; $subject="Details of the Person"; //format the message body //$message="This is the message body"; $fileatt= $_FILES['image']['tmp_name']; $fileatt_type= $_FILES['image']['type']; $fileatt_name= $_FILES['image']['name']; if (is_uploaded_file($fileatt)) { $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Base64 encode the file data $data = chunk_split(base64_encode($data)); } $semi_rand = md5(time()); $mime_boundary = ==Multipart_Boundary_x{$semi_rand}x"; $headers="From:"; // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; if ($fileatt_name > "") { $headers .= "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . $data . "\n" . "--{$mime_boundary}\n"; } $message .= "--$mime_boundary\n"; $message .= "Content-Type: text/html; charset=UTF-8\n"; $message .= "Content-Transfer-Encoding: 8bit\n\n"; $message.="<html>\n<body>\n<table><tr><td>FULL NAME: $fullname </td></tr>"; $message.="<tr><td>S/o W/o D/o:$relatednam</td></tr>"; $message.="<tr><td>GENDER:$gende</td></tr>"; $message.="<tr><td>APPROXAGE: $approxage </td></tr>" ; $message.="<tr><td>MISSING DATE: $missingdate </td></tr>" ; $message.="<tr><td>MISSING LOCATION: $missinglocation</td></tr>" ; $message.="<tr><td>ADDRESS: $address </td></tr>" ; $message.="<tr><td>PHONE: $phone </td></tr>" ; $message.="<tr><td>LANGUAGES: $languages </td></tr>" ; $message.="<tr><td>HEIGHT: $height </td></tr>" ; $message.="<tr><td>HAIR: $hair </td></tr>" ; $message.="<tr><td>COMPLEXION: $complexion </td></tr>" ; $message.="<tr><td>MENTAL CONDITION: $mentalcondition </td></tr>" ; $message.="<tr><td>LOCATION LAST SEEN: $lastseen </td></tr></table></body>\n</html>\n"; $message .= "--$mime_boundary--\n\n"; $message=wordwrap($message, 70); $ok = mail($to, $subject,$message,$headers); if ($ok) { header("Location: http://www.webmaster.com/unknown/missingcomplaint.php"); } else { echo "<p>Mail could not be sent. Sorry!</p>"; } } ?> Not able send the message which i have written in the php file. but image is recieved to the mail without message body. can any body help me out to solve this problem