ahs10 Posted September 26, 2008 Share Posted September 26, 2008 i get the email, the html links inside the message work, the file attaches with the correct name and filesize, but when you try to open the attachment it says it's corrupt. can someone help me please? $email_body = nl2br(html_entity_decode($_POST['email_body'])); $message = "--mimeBoundary\n" . "Content-Type: text/html; charset=UTF-8; format=flowed\n" . "Content-Transfer-Encoding: 8bit\n" . "<base href=http:// />" . $email_body; if ($num_attachments != 0) { $message .= "\n"; while ($row = mysql_fetch_array($attachment_query)) { $message .= "--mimeBoundary\n" . "Content-Type: " . $row['ftype'] . "; name=" . $row['fname'] . "\n" . "Content-Transfer-Encoding: base64\n" . "Content-Disposition: attachment\n" . base64_encode($row['fdata']); } $message .= "\n" . "--mimeBoundary--"; } $encoded_subject = "=?UTF-8?B?" . base64_encode($subject) . "?=\n"; $headers = "From: " . $userEmail . "\n" // . "Cc: " . $cc . "\n" // . "Bcc: " . $bcc . "\n" . "Content-Type: multipart/mixed; boundary=\"mimeBoundary\"\n" . "MIME-Version: 1.0\n" . "X-Mailer: PHP\n"; mail($to,$encoded_subject,$message,$headers); any help is much appreciated, thanks! Link to comment https://forums.phpfreaks.com/topic/125874-email-attachments/ Share on other sites More sharing options...
ahs10 Posted September 26, 2008 Author Share Posted September 26, 2008 i found a solution, but i don't know if it's a fix. if i change... . "Content-Type: " . $row['ftype'] . "; name=" . $row['fname'] . "\n" to... . "Content-Type: "binary/octet-stream; name=" . $row['fname'] . "\n" and this.... . base64_encode($row['fdata']); to this... . chunk_split(base64_encode($row['fdata'])); it all works properly. basically see that i am changing the file type of all files to one generic type and i'm splitting the data of the file up into smaller parts. how does this help? why didn't the first way work? Link to comment https://forums.phpfreaks.com/topic/125874-email-attachments/#findComment-651339 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.