<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<!---- FORMULAR ---->
<?php
$empf = "Max Mustermann <[email protected]>"; // HIER EMPFÄNGER ANPASSEN
$name = $_POST['name'];
$email = $_POST['email'];
$text = $_POST['text'];
$betreff = $_POST['betreff'];
// wenn das Formular übermittelt wurde
if(isset($_POST['abschicken']))
{
$mailnachricht.="\nDatum/Zeit: ". date("d.m.Y H:i:s");
// Überprüfen ob alle Pflichtfelder gefüllt sind
empty($name) ? $err[] = "<p>- Bitte den Namenangeben.</p>" : false;
empty($betreff) ? $err[] = "<p>- Bitte einen Betreff angeben.</p>" : false;
empty($email) ? $err[] = "<p>- Bitte die Email-Adresse angeben.</p>" : false;
empty($text) ? $err[] = "<p>- Bitte geben Sie Ihre Anfrage ein.</p>" : false;
// wenn nicht, werden die Fehlermeldungen ausgegeben und das "halbgefüllte" Formular angezeigt
if(!empty($err)) {
echo "<p>Bitte korrigieren Sie folgende Fehler:</p>";
foreach($err as $fehler){
echo $fehler;
} ?>
<form action="#" method="post">
<table width="500px" border="0" cellpadding="3" cellspacing="1">
<tr><td width="90px" align="right">Name:</td><td><img src="pics/pfeil.png" alt="Pflichtfeld"></td><td align="right"><input type="text" class="feld" name="name" value="<?php echo $name; ?>" style="width:300px;" /></td></tr>
<tr><td align="right">E-Mail:</td><td><img src="pics/pfeil.png" alt="Pflichtfeld"></td><td align="right"><input type="text" class="feld" name="email" value="<?php echo $email; ?>" style="width:300px" /></td></tr>
<tr><td align="right">Betreff:</td><td> </td><td align="right"><input type="text" class="feld" name="betreff" value="<?php echo $betreff; ?>" style="width:300px" /></td></tr>
</table>
<table width="500px" border="0" cellpadding="3" cellspacing="1">
<tr><td colspan="2"><textarea rows="12" class="feld" style="width:500px" name="text"><?php echo $text; ?></textarea></td></tr>
<tr><td colspan="2" align="left" nowrap><br /><input type="reset" value="Formular löschen" style="width:49%" /> <input type="submit" name="abschicken" class="button" value="Formular absenden" style="width:49%" /></td></tr>
</table>
</form>
<?php // sind keine Fehler vorhanden, wird die Email versendet
} else {
/* Um eine HTML-Mail zu senden, können Sie den den "Content-type"-Header setzen */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$CID = md5(uniqid (rand(), 1));
$mime_boundary = "" . md5(uniqid(mt_rand(), 1));
$headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"; type=\"text/plain\"\n";
$MailBody = "--".$mime_boundary."\n";
$MailBody.= "Content-Type: Text/HTML; charset=iso-8859-1$EOL";
$MailBody.= "Content-Transfer-Encoding: quoted-printable\n\n";
/* zusätzliche Header */
//$headers .= "To: ".$empf;
$headers .= "From: $vorname $nachname <$email>\r\n";
//$headers .= "Cc: $vorname $nachname <$email>\r\n";
$mailbetreff="Kontaktformular von ".$_SERVER['HTTP_HOST'];
$mailnachricht .= "<br><br><table width=\"100%\"><tr><td width=\"50%\"><table border=\"0\" width=\"100%\">" .
"<tr><td width=\"50%\">Nachname:</td><td width=\"50%\">" . $Name . "</td></tr>" .
"<tr><td width=\"50%\">eMail:</td><td width=\"50%\">" . $email . "</td></tr>" .
"<tr><td width=\"50%\">Betreff:</td><td width=\"50%\">" . $betreff . "</td></tr>" .
"</table></td><td width=\"50%\" align=\"right\" valign=\"top\"></td></tr></table><br><hr><br>Nachricht:<br>" . $text . "<br><hr><br>\nDatum/Zeit: ". date("d.m.Y H:i:s");
$MailBody .= $mailnachricht;
$MailBody.= "\n\n";
$MailBody.= "--".$mime_boundary."\n<br><br>";
$fp = fopen ($ImageLocation1, "rb");
$str = fread ($fp, filesize ($ImageLocation1));
$data = chunk_split(base64_encode($str));
$content.= "Content-Type: image/png\n";
$content.= "Content-ID: <$CID.$ImgName1>\n";
$content.= "Content-Transfer-Encoding: base64\n";
$content.= "Content-Disposition: inline; filename=\"$ImgName1\"\n\n";
$content.= $data;
$MailBody.= $content;
// HIER DIE EMPFÄNGER EMAIL-ADRESSE ANPASSEN!!!
if(mail($empf.", $mailbetreff, $MailBody, $headers)){
echo "<p><br><br><br>Vielen Dank für Ihre eMail!</p>";
} else {
echo "<br><br><br><p>Ein Fehler ist aufgetreten!</p>";
}
// das Formular welches als erstes dem Besucher angezeigt wird
}
}else{
?>
<form action="#" method="post">
<table width="500px" border="0" cellpadding="3" cellspacing="1">
<tr><td width="90px" align="right">Name:</td><<td align="right"><input type="text" class="feld" name="name" value="" style="width:300px;" /></td></tr>
<tr><td align="right">E-Mail:</td><td align="right"><input type="text" class="feld" name="email" value="" style="width:300px" /></td></tr>
<tr><td align="right">Betreff:</td><td align="right"><input type="text" class="feld" name="vorname" value="" style="width:300px" /></td></tr>
</table>
<table width="500px border="0" cellpadding="3" cellspacing="1">
<tr><td colspan="2"><textarea rows="8" class="feld" style="width:500px" name="text"></textarea></td></tr>
<tr><td colspan="2" align="left" nowrap><br /><input type="reset" class="send" value="Formular löschen" style="width:49%" /> <input type="submit" class="send" name="abschicken" value="Formular absenden" style="width:49%" /></td></tr>
</table>
</form>
<?php
}
?>
</body>
</html>