<?php
$email_betreff = "CMS_VALUE[0]";
$email_empfaenger = "CMS_VALUE[1]";
$email_cc = "CMS_VALUE[2]";
$email_bcc = "CMS_VALUE[3]";
$label_empf_name = "CMS_VALUE[4]";
$label_empf_email = "CMS_VALUE[5]";
$label_nachricht = "CMS_VALUE[6]";
$label_anhang = "CMS_VALUE[7]";
$senden_button = "CMS_VALUE[8]";
$erfolgreich_verschickt = "CMS_VALUE[9]";
$hinweisfeld = "CMS_VALUE[10]";
$error_1 = "CMS_VALUE[11]";
$error_2 = "CMS_VALUE[12]";
$error_3 = "CMS_VALUE[13]";
$error_4 = "CMS_VALUE[14]";
if( isset($senden) ) {
# Kein Absender-Name eingegeben
if( empty($absendername) ) {
$fehler1 = "<div class=\"vorspann\"><span style=\"color: red;\">$error_1</span></div>";
}
# Keine Absender-E-Mail eingegeben
$host_absender = substr(strstr($absender, '@'), 1);
if( empty($host_absender) ) {
$fehler2 = "<div class=\"vorspann\"><span style=\"color: red;\">$error_2</span></div>";
} else {
if( checkdnsrr($host_absender) == FALSE ) {
$fehler3 = "<div class=\"vorspann\"><span style=\"color: red;\">$error_2</span></div>";
}
}
# Keine Nachricht eingegeben
if( empty($msg) ) {
$fehler4 = "<div class=\"vorspann\"><span style=\"color: red;\">$error_3</span></div>";
}
# Betreff
$betreff = utf8_decode($betreff);
# Wichtigkeit
if( $priority == "high" ) {
$wichtigkeit = "X-Priority: 1 (Highest)\n" . "Importance: High\n";
}
if( $priority == "low" ) {
$wichtigkeit = "X-Priority: 5 (Lowest)\n" . "Importance: Low\n";
}
# Absender
if( !empty($absender) ) {
$from = "From: $absender\n";
}
# Kopie
if( !empty($cc) ) {
$cc = "Cc: $cc\n";
}
# Blind-Kopie
if( !empty($bcc) ) {
$bcc = "Bcc: $bcc\n";
}
# Antworten senden an
if( !empty($reply) ) {
$reply = "Reply-To: $reply\n";
} else {
$reply = "Reply-To: $absender\n";
}
$datei = $HTTP_POST_VARS['datei'];
$msg .= "Datei: " . $datei;
# Anhang
# Wenn eine Datei als Anhang ausgewählt wurde
if( !empty($datei) ) {
$test = "Hallo";
# Lese die temporaere Datei, die der Benutzer hochgeladen hat aus
$datei_content = fread(fopen($datei,"r"),filesize($datei));
# Codiere Datei ins BASE64-Format
$datei_content = chunk_split(base64_encode($datei_content));
# Generiere einen Boundary
$boundary = strtoupper(md5(uniqid(time())));
# Beginne den Mail-Header mit MIME-Mail-Header
$mail_header = "Content-Type: multipart/mixed; boundary=$boundary\n";
# Hier faengt der normale Mail-Text an
$mail_header .= "--$boundary\n";
# Format - (html o. txt)
if( $content_type == "html" ) {
$mail_header .= "Content-Type: text/plain\n";
$mail_header .= "Content-Transfer-Encoding: 7bit\n\n";
$msg = str_replace(chr(10),"",$msg);
$msg = utf8_decode($msg);
} else {
$mail_header .= "Content-Type: text/html\n";
$mail_header .= "Content-Transfer-Encoding: 8bit\n\n";
}
$mail_header .= "$msg\n\n";
# Hier faengt der Datei-Anhang an
$datei_name = utf8_decode($datei_name);
$mail_header .= "--$boundary\n";
$mail_header .= "Content-Type: application/octetstream; name=\"$datei_name\"\n";
# Codierung immer BASE64
$mail_header .= "Content-Transfer-Encoding: base64\n";
$mail_header .= "Content-Disposition: attachment; filename=\"$datei_name\"\n\n";
$mail_header .= "$datei_content\n";
# Gibt das Ende der eMail aus
$mail_header .= "--$boundary--\n";
} else {
$content_type = "Content-Type: text/plain\n";
$encoding = "Content-Transfer-Encoding: 7bit\n";
$msg = str_replace(chr(10),"",$msg);
$msg = utf8_decode($msg);
}
$i = 0;
if( empty($fehler1) && empty($fehler2) && empty($fehler3) && empty($fehler4) ) {
while( $i < $anzahl ) {
$header = "MIME-Version: 1.0\n"
. $from
. $reply
. $cc
. $bcc
. $mail_header
. $content_type
. $encoding
. $wichtigkeit;
mail($empfaenger,$betreff,$msg,$header);
$k = $i+1;
$i++;
}
echo "<div class=\"vorspann\">$erfolgreich_verschickt - $test</div>";
echo var_dump($datei);
echo "<br/>";
echo var_dump($absender);
}
};
?>
<?php if( empty($k) ) {
echo "<div class=\"vorspann\">$hinweisfeld</div>";
if( !empty($fehler1) || !empty($fehler2) || !empty($fehler3) || !empty($fehler4) ) {
echo "$fehler1";
echo "$fehler2";
echo "$fehler3";
echo "$fehler4";
}
echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"/cms/front_content.php?idcat=17\">
<fieldset>
<input type=\"hidden\" name=\"anzahl\" value=\"1\"/>
<input type=\"hidden\" name=\"priority\" value=\"\"/>
<input type=\"hidden\" name=\"empfaenger\" value=\"$email_empfaenger\"/>
<input type=\"hidden\" name=\"cc\" value=\"$email_cc\"/>
<input type=\"hidden\" name=\"bcc\" value=\"$email_bcc\"/>
<input type=\"hidden\" name=\"betreff\" value=\"$email_betreff\"/>
<input type=\"hidden\" name=\"reply\" value=\"\"/>
<label for=\"feld1\">$label_empf_name</label>
<p class=\"s2f\"><input id=\"feld1\" type=\"text\" name=\"absendername\" value=\"$absendername\"/></p>
<br class=\"clear\"/>
<br/>
<label for=\"feld2\">$label_empf_email</label>
<p class=\"s2f\"><input id=\"feld2\" type=\"text\" name=\"absender\" value=\"$absender\"/></p>
<br class=\"clear\"/>
<br/>
<label for=\"feld3\">$label_nachricht</label>
<p class=\"s2ftext\"><textarea id=\"feld3\" name=\"msg\" cols=\"30\" rows=\"10\" class=\"standard\">$msg</textarea></p>
<br class=\"clear\"/>
<br/>
<label for=\"feld4\">$label_anhang</label>
<p class=\"s2f\"><input id=\"feld4\" type=\"file\" name=\"datei\"></p>
<br class=\"clear\"/>
<br/>
<p>
<input class=\"submit\" type=\"submit\" name=\"senden\" value=\"$senden_button\"/>
</p>
</fieldset>
</form>";
}
?>