josephnwachukwu Posted June 8, 2008 Share Posted June 8, 2008 I cannot get this to send property. it just sends a bunch of text jibberish. Am i using the wrong encoding or file type? i don't know how to proceed. Is anyone else having this problem? Here is the code. $fileatt = "audio/" . $Location1; // Path to the file $fileatt_type = "(audio/mpeg)"; // File Type $fileatt_name = $Name1; // Filename that will be used for the file as the attachment //$email_from = ""; // Who the email is from //$headers = "From: ".$email_from; $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $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}\""; $message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; $data = chunk_split(base64_encode($data)); $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"; //$to = $_POST['number'] .'@' . $_POST['ctype']; $to = "[email protected]"; $headers = 'From: ' . $site_email . "\r\n" . 'Reply-To: ' . $site_email . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $subject = "Your song"; //$message .= $Name . ' ' . $Artist; if ( mail($to, $subject, $message, $headers ) ) { $msg = 'Your song has been sent.'; } else { $error = 'There was an error sending your song please try again'; } } Can anyone help? Link to comment https://forums.phpfreaks.com/topic/109238-sending-an-mp3-attachmet-using-mail/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.