nsarun Posted December 24, 2009 Share Posted December 24, 2009 Hi everybody.....I am trying email attachments....using PHP. Mail goes, mime boundaries are seen, but the attachment shows up as --==Multipart_Boundary_xea5f7ba2ae0131c78f0053adf34656c8x Content-Type: image/pjpeg; name="GreatBlue.jpg" Content-Disposition: attachment; filename="GreatBlue.jpg" Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIf IiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7 Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wAARCAMcBLADASIA AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA and so on.... --==Multipart_Boundary_xea5f7ba2ae0131c78f0053adf34656c8x-- I dont know what I am doing wrong......can somebody help me please.... Here is the code. $TO='ftlaudmedgroup@yahoo.com'; $HEADERS ='From: SRF - Ft. Lauderdale <ftlaudmedgroup@yahoo.com>'."\r\n"; $RECEP=$_POST['whoto'] ; $SUBJECT=$_POST['subject'] ; $MATTER=$_POST['matter']; $MATTER = nl2br($MATTER); $MATTER = stripslashes($MATTER); // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; //"application/octet-stream"; $fileatt_name = $_FILES['fileatt']['name']; $SIGNATURE= "Some signature"; error_reporting(E_ALL); echo $fileatt."is tmpname".$fileatt_type."is the type and the name is: ".$fileatt_name; $MATTER.=$SIGNATURE; $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); //$data = chunk_split(base64_encode($data)); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $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/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $MATTER . "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; if (mail($TO, $SUBJECT, $email_message, $HEADERS)==TRUE){ . . } and so on.... Thank you all for the help. Quote Link to comment https://forums.phpfreaks.com/topic/186276-php-email-attachment-shows-as-a-bunch-of-text-data/ Share on other sites More sharing options...
kcp4911 Posted December 26, 2009 Share Posted December 26, 2009 I am getting a similar problem. However, the script works on one server - but has the same problem that you are experiencing on another server. Sounds like server settings? Quote Link to comment https://forums.phpfreaks.com/topic/186276-php-email-attachment-shows-as-a-bunch-of-text-data/#findComment-984256 Share on other sites More sharing options...
nsarun Posted December 26, 2009 Author Share Posted December 26, 2009 I doubt it is the server....You think?? Quote Link to comment https://forums.phpfreaks.com/topic/186276-php-email-attachment-shows-as-a-bunch-of-text-data/#findComment-984291 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.