-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
65 lines (57 loc) · 3.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PHP-Mailer - Beispiele</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>E-Mails mittels PHP-Skript versenden</h1>
<h2>Grundlagen</h2>
<p>Hierzu stellt PHP die Funktion <b>mail()</b> zur Verfügung. Als Vorraussetzung wird hierfür ein lokal installierter SMTP-Server benötigt.
Unter Linux bzw. bei den Providern ist dies meistens der Fall. </p>
<h3>Die Funktion Mail</h3>
<p><strong>mail ($to, $subject, $message [, $additional_headers]
)</strong></p>
<p>Rückgabe:<br />
0 (false): Es ist ein Fehler aufgetreten, die Mail wurde nicht an den SMTP-Server
übergeben.<br />
1 (true):
Die Mail wurde korrekt an den SMTP-Server übergeben.</p>
<p>Parameter:<br />
<strong>$to: </strong>String der die Zieladresse beinhaltet<br />
$<strong>subject: </strong>String mit dem Inhalt der Betreffzeile<br />
<strong>$message</strong>: String mit dem Mailtext<br />
<strong>$additional_headers</strong>: Optionaler Parameter, mit dem weiteren
Mailkopfzeilen angegeben werden können (z.B. Ccc, Bcc, Reply-To, From , ..usw.).
Die einzelnen Header-Parameter sind durch einen Zeilenumbruch ( \n) zutrennen.</p>
<h2><a href="mailformular.html">Beispiel </a></h2>
<pre><?php<br />
$from=$HTTP_POST_VARS["recipient"];
$fmtResponse= implode("", file("anmeldung_okay.html"));
$fmtResponseerror= implode("", file("anmeldung_fehler.html"));
$fmtMail= implode("", file("anmeldung.txt"));
$str_logtext = "Rechner: " . gethostbyaddr($HTTP_SERVER_VARS["REMOTE_ADDR"]) . " (" . date("d.m.Y - H:i") . ")";
$fmtMail= str_replace("<loginfo>", $str_logtext, $fmtMail);
if ($HTTP_POST_VARS["Email"] != "") {
$from=$HTTP_POST_VARS["Email"];
}
$from="From: $from\nBCc: [email protected]";
foreach($HTTP_POST_VARS as $key=> $val)
if (is_array($val)) $val = implode(", ",$val); // wenn Array, dann Array zu String konvertieren
$fmtResponse= str_replace("<$key>", $val, $fmtResponse);
$fmtMail= str_replace("<$key>", $val, $fmtMail);
$fmtResponseerror= str_replace("<$key>", $val, $fmtResponseerror);
}
// eventuell nicht ausgefüllte Felder mit keine Angabe belegen
$fmtMail= str_replace("<Anfrage>", "keine Angabe", $fmtMail);<br /> $fmtMail= str_replace("<Anrede>", "keine Angabe", $fmtMail);<br /> $fmtMail= str_replace("<Land>", "keine Angabe", $fmtMail);<br /> $fmtMail= str_replace("<E-Mail>", "keine Angabe", $fmtMail);<br /> $fmtMail= str_replace("<Vorname>", "keine Angabe", $fmtMail);<br />
if ( @mail($HTTP_POST_VARS["recipient"], $HTTP_POST_VARS["subject"], $fmtMail, $from)) {<br /> echo $fmtResponse;<br /> }<br /> else { <br /> echo $fmtResponseerror;<br /> }</pre>
?></p>
<div align="left">
<hr>
<span style="font-size: 9px; text-align: right;">© by Geier99 2015</span>
<hr>
</div>
</body>
</html>