Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
<a href="mailto:webmaster@meinekleineschickeseite.de">Mail dem ollen Webmaster!</a>
<?php
# Maximale Größe des Attachments in Bytes:
$max_attach_size = 500000;
?>
<?php
if (isset($_POST["form_submitted"]))
{
// übergebene Variablen ermitteln:
$mailadressen = array();
$mailadressen["Privat"] = "XXXX@XXx.de";
$mailadressen["sonstiges"] = "XXXX@XXx.de";
$name = $_POST["vorname"]." ".$_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$text = $_POST["text"];
if(isset($mailadressen[$_POST["mailto"]])) {
$mailto = $mailadressen[$_POST["mailto"]];
} else {
die("Keinen gültigen Empfänger ausgewählt!");
}
// Überprüfungen der Daten:
unset($errors);
if ($email != "" and !preg_match("/^[^@]+@.+\.\D{2,5}$/", $email)) $errors[] = "die E-Mail-Adresse sieht nicht richtig aus";
if ($text == "") $errors[] = "es wurde kein Text eingegeben";
if ($_FILES['probe']['size'] > $max_attach_size) $errors[] = "Attachment zu groß (".number_format($_FILES['probe']['size']/1000,0,",","")." KB) - Maximalgröße: ".number_format($max_attach_size/1000,0,",","")." KB";
if (empty($errors))
{
$text = stripslashes($text);
$subject = stripslashes($subject);
if ($name != "") $mail_name=$name; else $mail_name="unbekannt";
if ($subject != "") $mail_subject = $subject; else $mail_subject = "kein Betreff";
if ($email != "") $mail_email = $email; else $mail_email = "XXX@XXx.de";
$ip = $_SERVER["REMOTE_ADDR"];
// Wenn Attachment, dann MIME-Mail erstellen:
if (isset($_FILES['probe']['name']) && trim($_FILES['probe']['name']) != "")
{
// Datei einlesen und codieren:
$datei_content = fread(fopen($_FILES['probe']['tmp_name'],"r"),filesize($_FILES['probe']['tmp_name']));
$datei_content = chunk_split(base64_encode($datei_content),76,"\n");
// Boundary festlegen:
$boundary = md5(uniqid(rand()));
// Mail-Header:
$mail_header = "From: ".$mail_name." <".$mail_email.">\n";
$mail_header .= "X-Sender-IP: ".$ip."\n";
$mail_header .= "MIME-Version: 1.0\n";
$mail_header .= "Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";
$mail_header .= "This is a multi-part message in MIME format.\n";
// Mail-Text:
$mail_header .= "--".$boundary;
$mail_header .= "\nContent-Type: text/plain";
$mail_header .= "\nContent-Transfer-Encoding: 8bit";
$mail_header .= "\n\n".$text;
// Attachment:
$mail_header .= "\n--".$boundary;
$mail_header .= "\nContent-Type: ".$_FILES['probe']['type']."; name=\"".$_FILES['probe']['name']."\"";
$mail_header .= "\nContent-Transfer-Encoding: base64";
$mail_header .= "\nContent-Disposition: attachment; filename=\"".$_FILES['probe']['name']."\"";
$mail_header .= "\n\n".$datei_content;
// Ende:
$mail_header .= "\n--".$boundary."--";
// Sende E-Mail und gebe Fehler bzw. Bestaetigung aus
if (@mail($mailto,$mail_subject,"",$mail_header)) $sent = true; else $errors[] = "keine Verbindung zum Mailserver - bitte nochmal versuchen";
}
// kein Attachment, normale E-Mail:
else
{
$mail_header = "From: ".$mail_name." <".$mail_email.">\n";
$mail_header .= "X-Sender-IP: $ip\n";
$mail_header .= "Content-Type: text/plain";
if (@mail($mailto,$mail_subject,$text,$mail_header)) $sent = true; else $errors[] = "keine Verbindung zum Mailserver - bitte nochmal versuchen";
}
// Kopie an Absender:
if (isset($sent) && isset($email) && $email != "" && isset($_POST['copy']))
{
if (isset($_FILES['probe']['name']) && trim($_FILES['probe']['name']) != "") $copy_mail_text = "Kopie der versendeten E-Mail:\n\n".$text."\n\nAttachment: ".$_FILES['probe']['name']; else $copy_mail_text = "Kopie der versendeten E-Mail:\n\n".$text;
$header= "From: ".$mailto."\n";
$header .= "X-Sender-IP: ".$ip."\n";
$header .= "Content-Type: text/plain";
@mail($email, $mail_subject, $copy_mail_text, $header);
}
}
}
if (empty($sent))
{
if(isset($errors))
{
?>
<p align="left" class="caution">Fehler:</p>
<div align="left">
<ul>
<?php foreach($errors as $f) { ?>
<li><?php echo $f; ?></li>
<?php } ?>
</ul>
<br />
<?php
}
?>
</div>
<form method="post" action="<?php echo basename($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">
<div>
<div align="left">
<table width="100%" border="0">
<tr>
<td width="23%" height="25"><p>Name: </p></td>
<td width="77%"><p>
<input name="name" type="text" class="chatfields" value="<?php if (isset($name)) echo htmlentities(stripslashes($name)); else echo ""; ?>" size="32" maxlength="255" />
</p></td>
</tr>
<tr>
<td height="29"><p>E-Mail: </p></td>
<td><p>
<input name="email" type="text" class="chatfields" value="<?php if (isset($email)) echo htmlentities(stripslashes($email)); else echo ""; ?>" size="32" maxlength="255" />
(dahin geht die Antwort) </p></td>
</tr>
<tr>
<td height="27"><p>Betreff:</p></td>
<td><p><b>
<input name="subject" type="text" class="chatfields" value="<?php if (isset($subject)) echo htmlentities(stripslashes($subject)); else echo ""; ?>" size="40" maxlength="40" />
</b></p></td>
</tr>
<tr>
<td height="28"> <p>Art der Anfrage :</p></td>
<td><p><b>
<select name="mailto" class="chatfields">
<option>-- bitte auswählen --</option>
<option value="privat">Privat</option>
<option value="sonstiges">Sonstiges</option>
</select>
</b></p></td>
</tr>
<tr>
<td height="105"><p>Nachricht: </p></td>
<td><p>
<textarea name="text" cols="75" rows="6" class="chatfields"><?php if (isset($text)) echo htmlentities(stripslashes($text)); else echo ""; ?>
</textarea>
</p></td>
</tr>
<tr>
<td><p>Attachment: </p></td>
<td><p>
<input name="probe" type="file" class="chatfields" value="<?php if (isset($_POST['probe'])) echo htmlentities(stripslashes($_POST['probe'])); else echo ""; ?>" size="20"/>
</p></td>
</tr>
</table>
</div>
<p align="left">
<input name="form_submitted" type="submit" class="chatfields" value=">>> Absenden" />
<input type="checkbox" name="copy" value="true" />
Kopie an Absender</p>
</div>
</form>
<?php
}
else
{
if (empty($email)) { ?>
<p align="left"><b>Danke!</b><br />
Nachricht erfolgreich versendet. Allerdings wurde keine E-Mail-Adresse angegeben, ich kann also nicht antworten.</p>
<?php }
else { ?>
<p align="left"><b>Danke!</b><br />
Nachricht erfolgreich versendet.</p>
<?php }
}
?>
<form method="get" action="mailto:webmaster@website.tld">
Betreff: <input type="text" name="subject"><br>
<textarea name="body"></textarea><br>
<button>Senden</button>
</form>
<html>
<head><title>Kontakt</title></head>
<body>
<?php
if ((isset($_POST['send'])) && (!empty($_POST['fromaddress'])) && (!empty($_POST['subject'])) && (!empty($_POST['text'])))
{
mail("webmaster@meinekleinelustigespassdomain.de",$_POST['subject'],$_POST['text'],"From: ".$_POST['fromaddress']);
}
?>
<form method="post" action="kontakt.php">
Deine eMail-Adresse:<input type="text" name="fromaddress"><br>
Betreff:<input type="text" name="subject"><br>
Nachricht:<textarea name="text"></textarea><br>
<input type="submit" name="send" value="Abschicken">
</form>
</body>
</html>
<?php
$attachedfiles=array();
$fromaddress="";
$mailto="";
$subject="";
$message="";
if (!empty($_POST))
{
$keys=array_keys($_POST);
for ($count=0;$count<count($keys);$count++)
{
if (substr($keys[$count],0,10)=="attachment")
{
$attachedfiles[]=$_POST[$keys[$count]];
}
}
}
if ((isset($_POST['attachfile'])) || (isset($_POST['removeattachment'])))
{
if (!empty($_POST['mailto']))
{
$mailto=$_POST['mailto'];
}
if (!empty($_POST['subject']))
{
$subject=$_POST['subject'];
}
if (!empty($_POST['message']))
{
$message=$_POST['message'];
}
if (isset($_POST['attachfile']))
{
$tmpname=$_FILES["uploadfile"]["tmp_name"];
$filename=$_FILES["uploadfile"]["name"];
$filesize=$_FILES["uploadfile"]["size"];
if ($filesize>0)
{
move_uploaded_file($tmpname,"mailtemp/".$filename);
$attachedfiles[]=$filename;
}
}
if (isset($_POST['removeattachment']))
{
for ($count=0;$count<count($keys);$count++)
{
if (substr($keys[$count],0,13)=="delattachment")
{
$filename=$_POST[$keys[$count]];
$delpositions[]=substr($keys[$count],13,1);
unlink("mailtemp/".$filename);
}
}
$newattachedfiles=array();
for ($count=0;$count<count($attachedfiles);$count++)
{
if (!in_array($count,$delpositions))
{
$newattachedfiles[]=$attachedfiles[$count];
}
}
$attachedfiles=$newattachedfiles;
unset($newattachedfiles);
}
}
if ((isset($_POST['sendmail'])) && (!empty($_POST['mailto'])) && (!empty($_POST['subject'])) && (!empty($_POST['message'])))
{
$message=imap_8bit($_POST['message']);
$message.="\n\n";
for ($attachment=0;$attachment<count($attachedfiles);$attachment++)
{
$message.="\t".imap_8bit("<<".$attachedfiles[$attachment].">>");
}
$boundary="----".md5(uniqid());
$email="";
$email.="Content-class: urn:content-classes:message";
$email.="\nUser-Agent: reptiler's lustiger mailer";
$email.="\nMIME-Version: 1.0";
if (!empty($attachedfiles))
{
$email.="\nContent-Type: multipart/mixed;\n\tboundary=\"".$boundary."\"";
}
$email.="\nFrom: ".$fromaddress;
$email.="\nX-Priority: 3 (Normal)";
$email.="\nImportance: Normal";
if (!empty($attachedfiles))
{
$email.="\n\n--".$boundary;
}
$email.="\nContent-Type: text/plain;\n\tcharset=\"iso-8859-1\"";
$email.="\nContent-Transfer-Encoding: quotet-printable";
$email.="\n\n".$message;
if (!empty($attachedfiles))
{
$email.="\n\n--".$boundary;
}
for ($attachment=0;$attachment<count($attachedfiles);$attachment++)
{
$file=fopen("mailtemp/".$attachedfiles[$attachment],"r");
$content=fread($file,filesize("mailtemp/".$attachedfiles[$attachment]));
fclose($file);
$encodedfile=chunk_split(base64_encode($content));
$email.="\nContent-Type: application/octet-stream;\n\tname=\"".$attachedfiles[$attachment]."\"";
$email.="\nContent-Transfer-Encoding: base64";
$email.="\nContent-Description: ".$attachedfiles[$attachment];
$email.="\nContent-Disposition: attachment;\n\tfilename=\"".$attachedfiles[$attachment]."\"";
$email.="\n\n".$encodedfile."\n\n--".$boundary;
unlink("mailtemp/".$attachedfiles[$attachment]);
}
if (!empty($attachedfiles))
{
$email.="--";
}
imap_mail($_POST['mailto'],$_POST['subject'],"",$email);
unset($body);
unset($message);
unset($attachedfiles);
$message="";
$attachedfiles=array();
}
echo '<html>';
echo '<body>';
echo '<form method="post" action="sendmail.php" enctype="multipart/form-data">';
echo 'Recipient:<input type="text" name="mailto" value="'.$mailto.'"><br>';
echo 'Subject:<input type="text" name="subject" value="'.$subject.'"><br>';
echo '<textarea name="message">'.$message.'</textarea><br>';
for ($attachment=0;$attachment<count($attachedfiles);$attachment++)
{
echo '<input type="hidden" name="attachment'.$attachment.'" value="'.$attachedfiles[$attachment].'">';
echo '<input type="checkbox" name="delattachment'.$attachment.'" value="'.$attachedfiles[$attachment].'">'.$attachedfiles[$attachment].'<br>';
}
if (count($attachedfiles)>0)
{
echo '<input type="submit" name="removeattachment" value="Remove selected attachments"><br>';
}
echo '<input type="file" name="uploadfile">';
echo '<input type="submit" name="attachfile" value="Attach file"><br>';
echo '<input type="submit" name="sendmail" value="Send eMail">';
echo '</form>';
echo '</body>';
echo '</html>';
?>