aktuelle.kurse/oldies/m133/Modul_Unterlagen_133_VOR/08-Uebungen/03 PHP Grundlagen/PHP_Referenz/funktionsreferenz/mail_funktionen/mail.html

340 lines
18 KiB
HTML
Raw Normal View History

2022-02-23 22:54:51 +01:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>mail</title>
<link rel="stylesheet" type="text/css" href="../../src/self.css">
<meta name="description" content="Versendet E-Mails">
<meta name="keywords" content="SELFPHP, PHP, Mail-Funktionen, mail">
<meta name="author" content="Damir Enseleit, mail@selfphp.info">
<meta name="DC.Contributer" content="Matthias Hupp, m.hupp@selfphp3.de">
<meta name="DC.Publisher" content="Damir Enseleit, mail@selfphp.info">
<meta name="DC.Date" content="2001-08-20T12:18+01:00">
<meta name="DC.Identifier" content="http://www.selfphp3.de/funktionsreferenz/mail_funktionen/mail.html">
<meta name="DC.Language" content="de">
<meta name="DC.Rights" content="../../editorial/index.html">
<meta name="SELF.Firstdate" content="2001-08-20T12:18+01:00">
<meta name="SELF.Version" content="1">
<meta name="SELF.Pagetype" content="Information">
<meta name="SELF.Path" content="SELFPHP == ../../index.php // Funktionsreferenz == ../index.php // Mail-Funktionen == index.html">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#AA5522" vlink="#772200" alink="#000000">
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#FFEEDD" class="nav"><a class="an" name="top"><img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"></a> <a href="../../index.html"><b>SELFPHP</b></a>/<a href="../../navigation/index.html">Navigationshilfen</a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"> <a href="../index.html"><b>Funktionsreferenz</b></a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"> <a href="index.html"><b>Mail-Funktionen</b></a></td>
</tr>
</table>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#EEEEEE" class="doc" width="110"><img src="../../src/logo.gif" width="106" height="109" border="0" alt="SEL.html"></td>
<td bgcolor="#EEEEEE" class="doc" valign="bottom" width="100%">
<h2>mail</h2></td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="doc" valign="top" align="center"> <img src="../../src/dokx.gif" width="30" height="20" vspace="6" border="0" alt="Informationsseite">
</td>
<td bgcolor="#FFFFFF" valign="top" nowrap colspan="2">
<p> <img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#befehl"><b>Befehl</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#version"><b>Version</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#beschreibung"><b>Beschreibung</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#beispiel1"><b>Beispiel1</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#ausgabe1"><b>Ausgabe1</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#beispiel2"><b>Beispiel2</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#ausgabe2"><b>Ausgabe2</b></a><br>
</p>
</td>
</tr>
<tr>
<td colspan=3 bgcolor="#EEEEEE" class="doc"><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;</td>
</tr>
</table>
<h2 class="Sh2"><a class="an" name="befehl">Befehl</a></h2>
<table width="100%" cellpadding=10><tr>
<td class="xmpcode" bgcolor="#E4EEFF">bool <b>mail</b>(string to, string subject,
string message [, string additional_headers])</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="version">Version</a></h2>
<table width="100%" cellpadding=10 height="32">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="20">
<p>PHP 3, PHP 4 &gt;= 4.0b1</p>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="beschreibung">Beschreibung</a></h2>
<table width="100%" cellpadding=10 height="247">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
<p>Mit mail() kann man eine E-Mail im Text- oder HTML-Format an eine oder<br>
mehrere Personen versenden. Sie k&ouml;nnen in dieser Mail einen Empf&auml;nger
(to),<br>
einen Absender, ein CC , ein BCC und sogar ein Attachment festlegen, die
alle<br>
beim Versand ber&uuml;cksichtigt werden. <br>
Der Betreff (subject) und die Nachricht (message) werden dann mit den
obigen<br>
Daten versendet. Im Mailheader (additional_headers) k&ouml;nnen Sie verschiedene<br>
Angaben (From, Cc, Bcc etc - siehe Beispiel) machen, welche jeweils durch<br>
einen Zeilenvorschub (\n) getrennt sein m&uuml;ssen. <br>
Wollen Sie eine E-Mail an mehrere Personen senden, so schreiben Sie sie
im to-<br>
Bereich und trennen die einzelnen Adressen durch ein Komma(,).<br>
Im optionalen Parameter additional_parameters k&ouml;nnen Sie<br>
Befehlszeilenargumente an das Mail-Programm &uuml;bergeben.</p>
<p>Zu Beispiel 1:<br>
Bei diesem Beispiel wurde per Formular eine HTML-Mail generiert und an
den<br>
Empf&auml;nger gesendet. Zus&auml;tzlich wurde eine zus&auml;tzliche E-Mail-Adresse
im BCC<br>
angegeben und weitergeleitet. Bedenken Sie bitte, dass Sie bei Einbindung
von<br>
Grafiken die absolute Adresse (im Internet) angeben m&uuml;ssen, da sonst
das Bild<br>
nicht angezeigt wird.<br>
Sie sollten aber lieber auf Grafiken verzichten, da der User beim Lesen
der<br>
Nachricht (wenn er offline ist) nicht sehr gl&uuml;cklich sein wird, dass
er online gehen<br>
muss, um sich die Grafik anzuschauen.</p>
<p>Zu Beispiel 2:<br>
Bei diesem Beispiel wurde per Formular (wie bei Beispiel 1) eine Text-Mail<br>
generiert und an den Empf&auml;nger gesendet. Zus&auml;tzlich wurde eine
E-Mail-Adresse<br>
im CC angegeben und weitergeleitet.</p>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="beispiel1">Beispiel1</a></h2>
<table width="100%" cellpadding=10 height="66">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF">
<pre>&lt;?PHP<br> //Wird vom Formular ausgefuellt<br> $email_to = &quot;$name_freund &lt;$email_freund&gt;&quot;; <br> //Absender-Email<br> $email_from_mail = &quot;mail@selfphp.info&quot;; <br> //Absender-Name<br> $email_from_name = &quot;Damir Enseleit&quot;; <br> //Betreff in der Mail<br> $email_betreff = &quot;Selfphp-Mailer&quot;;<br> //BCC<br> $email_to_bcc = &quot;mail@selfphp4.de&quot;;<br>?&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;Selfphp-Mailer&lt;/title&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#FFFFFF&quot;&gt;
&lt;h4&gt;Selfphp-Mailer&lt;/h4&gt;
&lt;?php
if(!isset($email_freund)){
?&gt;
&lt;form action=&quot;index.php&quot; method=&quot;post&quot;&gt;
&lt;table width=&quot;58%&quot; border=&quot;0&quot; cellspacing=&quot;2&quot; cellpadding=&quot;0&quot;&gt;
&lt;tr&gt;
&lt;td width=&quot;15%&quot; valign=&quot;top&quot;&gt;
Name/Freund:
&lt;/td&gt;
&lt;td width=&quot;85%&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;name_freund&quot;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;15%&quot; valign=&quot;top&quot;&gt;
Email/Freund:
&lt;/td&gt;
&lt;td width=&quot;85%&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;email_freund&quot;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;15%&quot; valign=&quot;top&quot;&gt;
Kommentar:
&lt;/td&gt;
&lt;td width=&quot;85%&quot;&gt;
&lt;textarea cols=&quot;30&quot; rows=&quot;6&quot; name=&quot;kommentar&quot;&gt;&lt;/textarea&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;15%&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;
&lt;td width=&quot;85%&quot;&gt;
&lt;input type=&quot;submit&quot; value=&quot;HTML-Mail senden&quot; name=&quot;submit&quot;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt; </pre>
<pre>&lt;?php
}
else{
$emailbody = '
&lt;html&gt;
&lt;!--
Hallo ' . $name_freund . '
Ihr System unterstuetzt keine HTML-Mails!
Folgende Nachricht wurde Ihnen uebermittelt:
' . $kommentar . '
--&gt;
&lt;body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;&gt;
&lt;table cellpadding=&quot;4&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot;&gt;
&lt;tr&gt;
&lt;td bgcolor=&quot;#FFEEDD&quot; &gt;
&lt;b&gt;SELFPHP: Version 1.0.0 , Autor: Damir Enseleit&lt;/b&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;table cellpadding=&quot;4&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot;&gt;
&lt;tr&gt;
&lt;td bgcolor=&quot;#EEEEEE&quot; &gt;
&lt;img src=&quot;http://www.selfphp3.de/src/logo.gif&quot; width=&quot;106&quot; height=&quot;109&quot; border=&quot;0&quot; alt=&quot;SELFHTML&quot;&gt;
&lt;/td&gt;
&lt;td bgcolor=&quot;#EEEEEE&quot; valign=&quot;bottom&quot; width=&quot;100%&quot;&gt;
Dynamische Webapplikationen:&lt;br&gt;
&lt;b&gt;PHP-Dateien selbst erstellen&lt;/b&gt;
&lt;h1&gt;Newsletter&lt;/h1&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td bgcolor=&quot;#EEEEEE&quot; valign=&quot;top&quot; align=&quot;center&quot;&gt;
&lt;h2&gt;Inhalt&lt;/h2&gt;
&lt;/td&gt;
&lt;td bgcolor=&quot;#FFFFFF&quot; valign=&quot;top&quot; width=&quot;100%&quot;&gt;
&lt;h2&gt;Hallo ' . $name_freund . '&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Das ist Deine Nachricht:&lt;/b&gt;&lt;/p&gt;
&lt;pre&gt;&lt;font face=&quot;Verdana,Geneva,Arial, Helvetica,sans-serif&quot; color=&quot;#006600&quot;&gt;'
. $kommentar .
'&lt;/font&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=2 bgcolor=&quot;#EEEEEE&quot; &gt;
&lt;img src=&quot;http://www.selfphp3.de/src/up.gif&quot; width=&quot;14&quot; height=&quot;10&quot; border=&quot;0&quot; alt=&quot;nachoben&quot;&gt;&amp;#160;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;&amp;copy; 2001&lt;img src=&quot;http://www.selfphp3.de/src/mail.gif&quot; width=&quot;15&quot; height=&quot;10&quot; border=&quot;0&quot; alt=&quot;E-Mail&quot;&gt;
&amp;nbsp;&lt;a href=&quot;mailto:mail@selfphp.info&quot;&gt;Damir Enseleit, mail@selfphp.info&lt;/a&gt;&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
'; </pre>
<pre>$header=&quot;From:$email_from_name&lt;$email_from_mail&gt;\n&quot;;
$header .= &quot;Reply-To: $email_from_mail\n&quot;;
$header .= &quot;Bcc: $email_to_bcc\n&quot;;
$header .= &quot;X-Mailer: PHP/&quot; . phpversion(). &quot;\n&quot;;
$header .= &quot;X-Sender-IP: $REMOTE_ADDR\n&quot;;
$header .= &quot;Content-Type: text/html&quot;;
mail($email_to,$email_betreff,$emailbody,$header);
echo &quot;&lt;p&gt;Sende Email nach: $email_freund&lt;br&gt;
Sende Email(BCC) nach: $email_from_mail&quot;;
}
?&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="ausgabe1">Ausgabe1</a></h2>
<table width="100%" cellpadding=10 height="45">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
<p><b>Ausf&uuml;llen des Formular:</b></p>
<p><img src="../funktionsgrafiken/mail_0.gif" width="394" height="430"></p>
<p><b>Best&auml;tigung beim Versenden:</b></p>
<p><img src="../funktionsgrafiken/mail_1.gif" width="394" height="269"></p>
<p><b>Fertige Email beim Empf&auml;nger:</b></p>
<p><img src="../funktionsgrafiken/mail_2.gif" width="396" height="611"></p>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="beispiel2">Beispiel2</a></h2>
<table width="100%" cellpadding=10 height="66">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF">
<pre>&lt;?PHP<br> //Wird vom Formular ausgefuellt<br> $email_to = &quot;$name_freund&lt;$email_freund&gt;&quot;; <br> //Absender-Email<br> $email_from_mail = &quot;mail@selfphp4.de&quot;; <br> //Absender-Name<br> $email_from_name = &quot;Damir Enseleit&quot;; <br> //Betreff in der Mail<br> $email_betreff = &quot;Selfphp-Mailer&quot;;<br> //CC<br> $email_to_cc=&quot;Matthias Hupp&lt;mail@selfphp.info&gt;&quot;;<br>?&gt;<br>&lt;html&gt;&lt;head&gt; <br>&lt;title&gt;Selfphp-Mailer&lt;/title&gt; <br>&lt;/head&gt;<br>&lt;body bgcolor=&quot;#FFFFFF&quot;&gt; <br>&lt;h4&gt;Selfphp-Mailer&lt;/h4&gt; <br>&lt;?php <br>if(!isset($email_freund)){ <br>?&gt;<br>&lt;form action=&quot;index.php&quot; method=&quot;post&quot;&gt; <br>&lt;table width=&quot;58%&quot; border=&quot;0&quot; cellspacing=&quot;2&quot; cellpadding=&quot;0&quot;&gt;<br> &lt;tr&gt;<br> &lt;td width=&quot;15%&quot; valign=&quot;top&quot;&gt;<br> Name/Freund:<br> &lt;/td&gt;<br> &lt;td width=&quot;85%&quot;&gt; <br> &lt;input type=&quot;text&quot; name=&quot;name_freund&quot;&gt;<br> &lt;/td&gt;<br> &lt;/tr&gt;<br> &lt;tr&gt;<br> &lt;td width=&quot;15%&quot; valign=&quot;top&quot;&gt;<br> Email/Freund:<br> &lt;/td&gt;<br> &lt;td width=&quot;85%&quot;&gt; <br> &lt;input type=&quot;text&quot; name=&quot;email_freund&quot;&gt;<br> &lt;/td&gt;<br> &lt;/tr&gt;<br> &lt;tr&gt;<br> &lt;td width=&quot;15%&quot; valign=&quot;top&quot;&gt;<br> Kommentar:<br> &lt;/td&gt;<br> &lt;td width=&quot;85%&quot;&gt; <br> &lt;textarea cols=&quot;30&quot; rows=&quot;6&quot;name=&quot;kommentar&quot;&gt;&lt;/textarea&gt;<br> &lt;/td&gt;<br> &lt;/tr&gt;<br> &lt;tr&gt;<br> &lt;td width=&quot;15%&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;<br> &lt;td width=&quot;85%&quot;&gt; <br> &lt;input type=&quot;submit&quot; value=&quot;HTML-Mail senden&quot; name=&quot;submit&quot;&gt;<br> &lt;/td&gt;<br> &lt;/tr&gt;
&lt;/table&gt;<br>&lt;/form&gt; <br>&lt;?php <br>} <br>else{ <br> $header=&quot;From:$email_from_name&lt;$email_from_mail&gt;\n&quot;; <br> $header .= &quot;Cc: $email_to_cc\n&quot;; <br> mail($email_to,$email_betreff,$kommentar,$header);<br>}<br>?&gt;</pre>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="ausgabe2">Ausgabe2</a></h2>
<table width="100%" cellpadding=10 height="45">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
<p><img src="../funktionsgrafiken/mail_3.gif" width="396" height="272"></p>
<p></p>
</td>
</tr></table>
<p>&nbsp;</p>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr><td colspan=2 bgcolor="#EEEEEE" class="doc">
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a>
</td></tr>
<tr>
<td bgcolor="#EEEEEE" class="doc" align="right" width="110">weiter:<a href="../mathematische_funktionen/index.html"><img src="../../src/next.gif" width="10" height="10" border="0" hspace="10" alt="weiter"></a></td>
<td bgcolor="#FFFFFF"><img src="../../src/dok.gif" width="15" height="10" border="0" alt="Seite">
<a href="../mathematische_funktionen/index.html"><b>Mathematische-Funktionen</b></a> </td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="doc" align="right" width="110">zur&uuml;ck:<a href="index.html"><img src="../../src/prev.gif" width="10" height="10" border="0" hspace="10" alt="zur&uuml;ck"></a></td>
<td bgcolor="#FFFFFF" width="100%"><img src="../../src/dok.gif" width="15" height="10" border="0" alt="Seite">
<a href="index.html"><b>Mail-Funktionen</b></a> </td>
</tr>
<tr><td colspan=2 bgcolor="#EEEEEE" class="doc">&#160;</td></tr>
</table><table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#FFEEDD" class="nav"><a class="an" name="bottom"><img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"></a>
<a href="../../index.html"><b>SELFPHP</b></a>/<a href="../../navigation/index.html">Navigationshilfen</a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von">
<a href="../index.html"><b>Funktionsreferenz</b></a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von">
<a href="index.html"><b>Mail-Funktionen</b></a></td>
</tr>
</table>
<p><a class="an" name="bottom">&copy; 2001, 2002, 2003</A> <img src="../../src/mail.gif" width="15" height="10" border="0" alt="E-Mail">&nbsp;<a href="mailto:mail@selfphp.info">Damir Enseleit, mail@selfphp.info</a></p>
</body>
</html>