PHP mail funktion med mp3 infogning
Jag har fått det fungera så långt att mailet skickas med den mp3 filen som man laddade upp...fast problemet är att den är tom :/ Någon som har någon aning hur jag ska kunna gå tillväga?
PS. Jag vill använda mig av php mail funktionen, inte av någon annan som typ swiftmailer osv
$temp_file = ini_set('upload_tmp_dir');
$fil = $formValues->file1;
move_uploaded_file($fil, $temp_file);
$email_to = "lill_z4ck3@hotmail.com"; // The email you are sending to (example)
$email_from = "sendfrom@email.com"; // The email you are sending from (example)
$email_subject = "subject line"; // The Subject of the email
$email_txt = "text body of message"; // Message that the email has in it
$fileatt = $temp_file; // Path to the file (example)
$fileatt_type = "audio/mpeg"; // File Type
$fileatt_name = "musik1"; // Filename that will be used for the file as the attachment
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers="From: $email_from"; // Who the email is from (example)
$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" . $email_txt;
$email_message .= "\n\n";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
$mail = mail($email_to,$email_subject,$email_message,$headers);
Tack i förhand,
Adam