Lid |
|
Hallo
Kan iemand de fout in deze code vinden?
Mijn berichttekst wordt goed verstuurd maar niet de bijlage!! deze blijkt leeg te zijn volgens mijn mailprogramma! Hoe komt dat?
Ziehier mijn code:
<?
function bijlage() {
global $bijlage, $bijlage_type, $bijlage_name, $bijlage_size, $headers, $message, $van;
$van = "info@ideeenhuisgeraardsbergen.be";
$bijlage_naam = $_FILES['bijlage']['name'];
$bijlage_type = $_FILES['bijlage']['type'];
$bijlage_size = $_FILES['bijlage']['size'];
$message = $_POST['bericht'];
//echo "Bericht:<br>".$message;
//echo "bijlage: ".$_FILES['bijlage']['name']."<br>";
//if($bijlage=="none")
//$pos = strpos($message,"<html>");
//$message = stripslashes($message);
//if($pos===false)
//{
$message = "<html><head><title></title>
<body>".$message."</body></html>";
//}
if($bijlage_naam=="")
{
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From:" .$van."\r\n";
$headers .= "Reply-To: ".$van."\r\n";
$headers .= "Return-Path: ".$van."\r\n";
}else{
$boundary=uniqid("");
$headers = "From: ".$van."\r\n".
"Reply-To:".$van."\r\n".
"Content-type: multipart/mixed; boundary=\"$boundary\"";
if ($bijlage_type) $mimeType = $bijlage_type;
else $mimeType = "application/unknown";
$fileName = $bijlage_naam;
$fp = fopen($_FILES['bijlage']['tmp_name'], "r");
$read = fread($fp, $_FILES['bijlage']['size']);
$read = base64_encode($read);
$read = chunk_split($read);
$message = "--$boundary
Content-type: text/html; charset=iso-8859-1
Content-transfer-encoding: 8bit
$message
--$boundary
Content-type: $mimeType; name=$fileName
Content-disposition: attachment; filename=$fileName
Content-transfer-encoding: base64
$read
--$boundary--";
}//end if bijlage
}//end bijlage()
?>
<html>
<head>
<title></title>
<script type="text/javascript" src="../ajax.js"></script>
<script type="text/javascript" src="../tinymce/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple"
});
function formcheck() {
ond=document.frmgroep.Onderwerp.value;
if(ond=="") {
alert("Gelieve het onderwerp in te vullen!");
document.frmgroep.Onderwerp.focus();
return false;
}
vraag=confirm("Weet je zeker dat je deze mail sturen?")
if (vraag==true) {
alert("De gegevens worden nu verzonden!");
}
else {
return vraag;
}
}
}
//-->
</script>
</head>
<body>
<a href="./menu.php">Hoofdmenu</a> <br>
<h1>Groepsmail versturen</h1>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" onSubmit="return formcheck()" name="frmgroep" id="frmgroep">
<table>
<tr>
<td>Onderwerp:</td>
<td><input type="text" name="Onderwerp" size="50"></td>
</tr>
<tr>
<td>Bijlage:</td>
<td><input name="bijlage" type="file"></td>
</tr>
</table>
Bericht: <br>
<textarea name="bericht" rows="10" cols="100">
<br><br>
Ideeenhuis Geraardsbergen<br>
Marcel De Sloover<br>
Vredestraat 20<br>
0494 45 29 15<br>
9500 Geraardsbergen<br>
info@ideeenhuisgeraardsbergen.be<br>
www.ideeenhuisgeraardsbergen.be
</textarea>
<br><input type="submit" name="verzenden" value="Verzenden">
</form>
<?
if (isset($_POST['verzenden'])) {
bijlage();
$subject = $_POST['Onderwerp'];
$to = "joris.vroem@belgacom.net";
if(mail($to, $subject, $message, $headers))
echo "<br>Verstuurd naar:".$to;
else
echo "<br>Niet verstuurd naar ".$to;
}//end if verzenden
?>
</body>
</html>
<? function bijlage() { global $bijlage, $bijlage_type, $bijlage_name, $bijlage_size, $headers, $message, $van; $van = "info@ideeenhuisgeraardsbergen.be"; $bijlage_naam = $_FILES['bijlage']['name']; $bijlage_type = $_FILES['bijlage']['type']; $bijlage_size = $_FILES['bijlage']['size']; $message = $_POST['bericht']; //echo "Bericht:<br>".$message; //echo "bijlage: ".$_FILES['bijlage']['name']."<br>"; //if($bijlage=="none") //$pos = strpos($message,"<html>"); //$message = stripslashes($message); //if($pos===false) //{ $message = "<html><head><title></title> <body>".$message."</body></html>"; //} if($bijlage_naam=="") { $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From:" .$van."\r\n"; $headers .= "Reply-To: ".$van."\r\n"; $headers .= "Return-Path: ".$van."\r\n"; }else{ $headers = "From: ".$van."\r\n". "Reply-To:".$van."\r\n". "Content-type: multipart/mixed; boundary=\"$boundary\""; if ($bijlage_type) $mimeType = $bijlage_type; else $mimeType = "application/unknown"; $fileName = $bijlage_naam; $fp = fopen($_FILES['bijlage']['tmp_name'], "r"); $read = fread($fp, $_FILES['bijlage']['size']); $message = "--$boundary Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: 8bit $message --$boundary Content-type: $mimeType; name=$fileName Content-disposition: attachment; filename=$fileName Content-transfer-encoding: base64 $read --$boundary--"; }//end if bijlage }//end bijlage() ?> <html> <head> <title></title> <script type="text/javascript" src="../ajax.js"></script> <script type="text/javascript" src="../tinymce/tinymce/jscripts/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> tinyMCE.init({ mode : "textareas", theme : "simple" }); function formcheck() { ond=document.frmgroep.Onderwerp.value; if(ond=="") { alert("Gelieve het onderwerp in te vullen!"); document.frmgroep.Onderwerp.focus(); return false; } vraag=confirm("Weet je zeker dat je deze mail sturen?") if (vraag==true) { alert("De gegevens worden nu verzonden!"); } else { return vraag; } } } //--> </script> </head> <body> <a href="./menu.php">Hoofdmenu</a> <br> <h1>Groepsmail versturen</h1> <form action=" <? echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" onSubmit="return formcheck()" name="frmgroep" id="frmgroep"> <table> <tr> <td>Onderwerp:</td> <td><input type="text" name="Onderwerp" size="50"></td> </tr> <tr> <td>Bijlage:</td> <td><input name="bijlage" type="file"></td> </tr> </table> Bericht: <br> <textarea name="bericht" rows="10" cols="100"> <br><br> Ideeenhuis Geraardsbergen<br> Marcel De Sloover<br> Vredestraat 20<br> 0494 45 29 15<br> 9500 Geraardsbergen<br> info@ideeenhuisgeraardsbergen.be<br> www.ideeenhuisgeraardsbergen.be </textarea> <br><input type="submit" name="verzenden" value="Verzenden"> </form> <? if (isset($_POST['verzenden'])) { bijlage(); $subject = $_POST['Onderwerp']; $to = "joris.vroem@belgacom.net"; if(mail($to, $subject, $message, $headers)) echo "<br>Verstuurd naar:".$to; else echo "<br>Niet verstuurd naar ".$to; }//end if verzenden ?> </body> </html>
|