mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Added example to show complex email, some formatting.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@33598 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
df97f4e4e5
commit
2224d120e0
1 changed files with 48 additions and 3 deletions
|
@ -20,14 +20,18 @@
|
|||
<paramdef>string <parameter>to</parameter></paramdef>
|
||||
<paramdef>string <parameter>subject</parameter></paramdef>
|
||||
<paramdef>string <parameter>message</parameter></paramdef>
|
||||
<paramdef>string <parameter><optional>additional_headers</optional></parameter></paramdef>
|
||||
<paramdef>string
|
||||
<parameter><optional>additional_headers</optional>
|
||||
</parameter>
|
||||
</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<simpara>
|
||||
<function>Mail</function> automatically mails the message specified
|
||||
in <parameter>message</parameter> to the receiver specified in
|
||||
<parameter>to</parameter>. Multiple recipients can be specified by
|
||||
putting a comma between each address in <parameter>to</parameter>.</simpara>
|
||||
putting a comma between each address in <parameter>to</parameter>.
|
||||
</simpara>
|
||||
<para>
|
||||
<example>
|
||||
<title>Sending mail.</title>
|
||||
|
@ -46,7 +50,48 @@ mail("rasmus@lerdorf.on.ca", "My Subject", "Line 1\nLine 2\nLine 3");
|
|||
mail("nobody@aol.com", "the subject", $message,
|
||||
"From: webmaster@$SERVER_NAME\nReply-To: webmaster@$SERVER_NAME\nX-Mailer: PHP/" . phpversion());
|
||||
</programlisting>
|
||||
</example></para>
|
||||
</example>
|
||||
You can also use fairly simple string building techniques to
|
||||
build complex email messages.
|
||||
<example>
|
||||
<title>Sending complex email.</title>
|
||||
<programlisting>
|
||||
/* recipients */
|
||||
$recipient .= "Mary <mary@u.college.edu>" . ", " ; //note the comma
|
||||
$recipient .= "Kelly <kelly@u.college.edu> . ", ";
|
||||
$recipient .= "ronabop@php.net";
|
||||
|
||||
/* subject */
|
||||
$subject = "Birthday Reminders for August";
|
||||
|
||||
/* message */
|
||||
$message .= "The following email includes a formatted ASCII table\n";
|
||||
$message .= "Day \t\tMonth \t\tYear\n";
|
||||
$message .= "3rd \t\tAug \t\t1970\n";
|
||||
$message .= "17rd\t\tAug \t\t1973\n";
|
||||
|
||||
/* you can add a stock signature */
|
||||
$message .= "--\r\n"; //Signature delimiter
|
||||
$message .= "Birthday reminder copylefted by public domain";
|
||||
|
||||
/* additional header pieces for errors, From cc's, bcc's, etc */
|
||||
|
||||
$headers .= "From: Birthday Reminder <birthday@php.net>\n";
|
||||
$headers .= "X-Sender: <birthday@php.net>\n";
|
||||
$headers .= "X-Mailer: PHP\n"; // mailer
|
||||
$headers .= "X-Priority: 1\n"; // Urgent message!
|
||||
$headers .= "Return-Path: <birthday@php.net>\n"; // Return path for errors
|
||||
|
||||
$headers .= "Content-Type: text/html; charset=iso-8859-1\n" // Mime type
|
||||
|
||||
$headers .= "cc:birthdayarchive@php.net\n"; // CC to
|
||||
$headers .= "bcc:birthdaycheck@php.net, birthdaygifts@php.net\n"; // BCCs to
|
||||
|
||||
/* and now mail it */
|
||||
mail($recipent, $subject, $message, $headers);
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
|
Loading…
Reference in a new issue