<?php
/*
* Mailskript für michael-puff.de
* Autor: Michael Puff
* Datum: 2010-09-23
*/
define("TO", "webmaster@michael-puff.de");
define("INVALID_ADDRESS_TEXT", "<p>Die angegebene E-Mail Adresse ist ungültig</p>");
define("INVALID_FIELDS_TEXT", "<p>Füllen Sie mindestens die mit * gekennzeichneten Felder aus und überprüfen Sie ihre E-Mail Adresse auf Gültigkeit.</p>
<p>Benutzen Sie die Zurück-Schaltefläche Ihres Browsers, um zum Kontaktformular zurück zu gelangen.</p>");
define("SUCCESS_TEXT", "<p>Die E-Mail wurde erfolgreich versendet.</p>");
define("SEND_ERROR_TEXT", "<p>Es ist ein Fehler beim Senden der E-Mail aufgetreten.</p>");
define("CHARSET", "UTF-8");
$from = $_POST['from'];
$yourname = $_POST['yourname'];
$subject = $_POST['subject'];
$msg = $_POST['text'];
$msg = stripslashes($msg);
function validateEmail($email) {
$regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
$valid = 0;
if (eregi($regexp, $email)) {
list($username,$domaintld) = split("@",$email);
if (getmxrr($domaintld,$mxrecords))
$valid = 1;
} else {
$valid = 0;
}
return $valid;
}
function htmlOutput($text) {
echo "<!DOCTYPE
html PUBLIC \"-//
W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
echo "<
html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"de\">\n";
echo "\t<head>\n";
echo "\t\t<meta http-equiv=\"content-type\" content=\"text/
html; charset=UTF-8\" />\n";
echo "\t\t<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n";
echo "\t\t<meta name=\"author\" content=\"Michael Puff\" />\n";
echo "\t\t<meta name=\"robots\" content=\"follow\" />\n";
echo "\t\t<meta name=\"language\" content=\"de\" />\n";
echo "\t\t<meta name=\"keywords\" content=\"\" />\n";
echo "\t\t<meta name=\"description\" content=\"\" />\n";
echo "\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"/data/stylesheet.css\" media=\"screen\" />\n";
echo "\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"/data/print.css\" media=\"print\" />\n";
echo "\t\t<title>E-Mail versenden</title>\n";
echo "\t</head>\n";
echo "\t<body>\n";
include ("nav.html");
echo "\t\t\t<h1>E-Mail versenden</h1>\n";
echo "\t\t<hr>\n";
echo "\t\t".$text."\n";
echo "\t\t<hr>\n";
echo "\t\t<center>".date("r", filectime("mail.php"))."</center>\n";
echo "\t</body>\n";
echo "</
html>\n";
}
function sendMail($to, $subject, $msg, $yourname, $from) {
$headers = "MIME-Version: 1.0\n".
"Content-Type: text/plain; charset=".CHARSET."\n".
"From: \"".$yourname."\" <".$from.">\n".
"Date: ".date("r")."\n";
return @mail($to, $subject, $msg, $headers);
}
if(!validateEmail($from)) {
htmlOutput(INVALID_ADDRESS_TEXT);
die();
}
if (empty($from) || empty($subject) || empty($msg) || (!validateEmail($from)))
{
htmlOutput(INVALID_FIELDS_TEXT);
die();
}
if (sendMail(TO, $subject, $msg, $yourname, $from)) {
htmlOutput(SUCCESS_TEXT);
die();
}
else {
htmlOutput(ERROR_SEND_TEXT);
die();
}
?>