Ik heb de volgende websites geraadpleegt:
http://www.phphulp.nl/php/scripts/1/262/
http://www.zend.com/zend/spotlight/sendmimeemailpart1.php
http://www.sitepoint.com/article/advanced-email-php/5
Zodoende ben ik tot het volgende voorbeeldje gekomen:
<?php
if(isset($_POST['submit'])){
//scheidingsteken voor het e-mailtje (boundary)
$bound = "web123456789core";
//tekst uit het formulier
$eigenaar = "Gert-Jan Bierkens";
$mail_eigenaar = "[email protected]";
$bezoeker = "John Johnson";
$mail_bezoeker = "[email protected]";
$titel = "titel";
$bericht = "test";
//het ge-uploade bestand
$upload = $_FILES['upload']['tmp_name'];
$bestandstype = $_FILES['upload']['type'];
$bestandsnaam = $_FILES['upload']['name'];
//het bestand openen (read binary)
if (is_uploaded_file($upload)) {
$bestand = fopen($upload,'rb');
$inhoud = fread($bestand,filesize($upload));
fclose($bestand);
}
//headers voor mixed content
$headers = "From: " . $eigenaar . " <" . $mail_eigenaar . ">\r\n";
$headers .= "To: " . $bezoeker . " <" . $mail_bezoeker . ">\r\n";
$headers .= "Subject: " . $titel . "\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed;";
$headers .= "boundary=\"" . $bound . "\";";
$headers .= "Content-Disposition: attachment\r\n";
$body = "--" . $bound;
$body .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$body .= "Content-Transfer-Encoding: 7bit\r\n";
$body .= $bericht;
$body .= "--" . $bound;
$body .= "Content-Type: application/octet-stream; name=" . $bestandsnaam . "\r\n";
$body .= "Content-Transfer-Encoding: base64\r\n";
$body .= "Content-disposition: attachment\r\n";
$body .= chunk_split(base64_encode($inhoud)) . "\r\n";
$body .= "--" . $bound; "--";
mail($mail_eigenaar, $titel, $body, $headers);
}
?>
<form enctype="multipart/form-data" method="post" action="">
<input type="file" name="upload" />
<input type="submit" value="Verzenden" name="submit" />
</form>
</body>
</html>
De mail wordt verzonden, maar op 1 of andere manier pakt ie die headers niet :D Ik heb hier al vaker mee gestoeid... en op 1 of andere manier doe ik altijd iets fout met de headers (althans... dat denk ik) kan iemand me helpen?