2001-08-19 11:47:45 +00:00
|
|
|
<?xml encoding="iso-8859-1"?>
|
|
|
|
<!-- $Revision: 1.26 $ -->
|
1999-06-06 18:51:02 +00:00
|
|
|
<reference id="ref.mail">
|
1999-06-20 03:04:56 +00:00
|
|
|
<title>Mail functions</title>
|
1999-06-06 18:51:02 +00:00
|
|
|
<titleabbrev>Mail</titleabbrev>
|
|
|
|
<partintro>
|
2001-02-05 23:24:01 +00:00
|
|
|
<simpara>
|
|
|
|
The <function>mail</function> function allows you to send mail
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</partintro>
|
|
|
|
|
|
|
|
<refentry id="function.mail">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>mail</refname>
|
|
|
|
<refpurpose>send mail</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>bool <function>mail</function></funcdef>
|
|
|
|
<paramdef>string <parameter>to</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>subject</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>message</parameter></paramdef>
|
2001-07-07 08:36:54 +00:00
|
|
|
<paramdef>string
|
2001-02-05 22:55:59 +00:00
|
|
|
<parameter><optional>additional_headers</optional></parameter>
|
|
|
|
</paramdef>
|
2001-07-07 08:36:54 +00:00
|
|
|
<paramdef>string
|
2001-02-05 21:50:59 +00:00
|
|
|
<parameter><optional>additional_parameters</optional>
|
|
|
|
</parameter>
|
2000-10-11 05:37:00 +00:00
|
|
|
</paramdef>
|
2000-06-24 07:38:45 +00:00
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
2001-06-23 20:10:52 +00:00
|
|
|
<function>mail</function> automatically mails the message
|
2001-05-22 02:13:37 +00:00
|
|
|
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
|
2001-07-07 08:36:54 +00:00
|
|
|
<parameter>to</parameter>. Email with attachments and special
|
|
|
|
types of content can be sent using this function. This is
|
|
|
|
accomplished via MIME-encoding - for more information, see
|
|
|
|
<ulink url="http://www.zend.com/zend/spotlight/sendmimeemailpart1.php"
|
|
|
|
>http://www.zend.com/zend/spotlight/sendmimeemailpart1.php</ulink> or
|
|
|
|
RFC 1896 (Visit <ulink url="http://www.rfc-editor.org/"
|
|
|
|
>http://www.rfc-editor.org/</ulink>).
|
2000-10-11 05:37:00 +00:00
|
|
|
</simpara>
|
2001-05-11 07:31:28 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
<function>mail</function> returns &true; if the mail
|
|
|
|
is sucessfully sent, &false; otherwise.
|
2001-05-11 07:31:28 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>Sending mail.</title>
|
|
|
|
<programlisting>
|
|
|
|
mail("rasmus@lerdorf.on.ca", "My Subject", "Line 1\nLine 2\nLine 3");
|
|
|
|
</programlisting>
|
1999-10-20 22:41:42 +00:00
|
|
|
</example></para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
If a fourth string argument is passed, this string is inserted at
|
|
|
|
the end of the header. This is typically used to add extra
|
2001-02-05 21:50:59 +00:00
|
|
|
headers. Multiple extra headers are separated with a newline.
|
|
|
|
</simpara>
|
2001-05-22 02:13:37 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
On Win32 systems, you must use <literal>\r\n</literal> to
|
|
|
|
seperate headers. Please also note that the cc: and bcc: headers
|
|
|
|
are case sensitve and should be written as <literal>Cc:</literal>
|
|
|
|
and <literal>Bcc:</literal> on Win32 systems.
|
|
|
|
</para>
|
|
|
|
</note>
|
2001-02-05 21:50:59 +00:00
|
|
|
<simpara>
|
|
|
|
If the fifth parameter is supplied, PHP will add this data
|
|
|
|
to the call to the mailer. This is useful when setting the
|
|
|
|
correct Return-Path header when using sendmail.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>Sending mail with extra headers.</title>
|
|
|
|
<programlisting>
|
|
|
|
mail("nobody@aol.com", "the subject", $message,
|
|
|
|
"From: webmaster@$SERVER_NAME\nReply-To: webmaster@$SERVER_NAME\nX-Mailer: PHP/" . phpversion());
|
|
|
|
</programlisting>
|
2000-10-11 05:37:00 +00:00
|
|
|
</example>
|
2001-02-05 21:50:59 +00:00
|
|
|
With the fifth parameter you can set additional command line parameters to
|
|
|
|
the actual mailer. In the example below we set the correct Return-Path
|
|
|
|
header for sendmail. Normally sendmail will add the X-Authentication-Warning
|
|
|
|
header when using the -f parameter, because the webserver user is probably
|
|
|
|
not a member of the trusted users. To suppress this warning, you should add
|
|
|
|
the web server user to the trusted users in your sendmail config file.
|
2001-02-16 00:47:33 +00:00
|
|
|
</para>
|
|
|
|
<note>
|
|
|
|
<para>
|
2001-02-15 18:11:57 +00:00
|
|
|
This fifth parameter was added in PHP 4.0.5.
|
2001-02-16 00:47:33 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
<para>
|
2001-02-05 21:50:59 +00:00
|
|
|
<example>
|
|
|
|
<title>Sending mail with extra headers and setting an additional command line parameter.</title>
|
|
|
|
<programlisting>
|
|
|
|
mail("nobody@aol.com", "the subject", $message,
|
|
|
|
"From: webmaster@$SERVER_NAME", "-fwebmaster@$SERVERNAME");
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
2000-10-11 05:37:00 +00:00
|
|
|
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
|
2001-02-10 17:02:08 +00:00
|
|
|
$recipient .= "Kelly <kelly@u.college.edu>" . ", ";
|
2000-10-11 05:37:00 +00:00
|
|
|
$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";
|
|
|
|
|
2001-07-07 08:36:54 +00:00
|
|
|
/* you can add a stock signature */
|
2000-10-11 05:37:00 +00:00
|
|
|
$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";
|
2001-07-07 08:36:54 +00:00
|
|
|
$headers .= "X-Sender: <birthday@php.net>\n";
|
2000-10-11 05:37:00 +00:00
|
|
|
$headers .= "X-Mailer: PHP\n"; // mailer
|
|
|
|
$headers .= "X-Priority: 1\n"; // Urgent message!
|
|
|
|
$headers .= "Return-Path: <birthday@php.net>\n"; // Return path for errors
|
|
|
|
|
2000-10-27 08:00:26 +00:00
|
|
|
/* If you want to send html mail, uncomment the following line */
|
|
|
|
// $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
|
2000-10-11 05:37:00 +00:00
|
|
|
|
2001-05-22 14:36:41 +00:00
|
|
|
$headers .= "cc: birthdayarchive@php.net\n"; // CC to
|
2001-07-22 09:35:48 +00:00
|
|
|
$headers .= "bcc: birthdaycheck@php.net, birthdaygifts@php.net"; // BCCs to
|
2000-10-11 05:37:00 +00:00
|
|
|
|
|
|
|
/* and now mail it */
|
2000-10-21 22:37:58 +00:00
|
|
|
mail($recipient, $subject, $message, $headers);
|
2000-10-11 05:37:00 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
2001-04-23 21:35:33 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
Make sure you have no new-line (or other whitespace) after your to or
|
|
|
|
subject parameters, as this may cause strange results.
|
|
|
|
</para>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-06-29 12:11:24 +00:00
|
|
|
<refentry id="function.ezmlm-hash">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>ezmlm_hash</refname>
|
|
|
|
<refpurpose>Calculate the hash value needed by EZMLM</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>ezmlm_hash</function></funcdef>
|
|
|
|
<paramdef>string <parameter>addr</parameter></paramdef>
|
2000-07-01 21:36:42 +00:00
|
|
|
</funcprototype>
|
2000-06-29 12:11:24 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
2000-07-01 21:36:42 +00:00
|
|
|
<function>ezmlm_hash</function> calculates the hash value needed
|
|
|
|
when keeping EZMLM mailing lists in a MySQL database.
|
|
|
|
</simpara>
|
2000-06-29 12:11:24 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
2000-07-01 21:36:42 +00:00
|
|
|
<title>Calculating the hash and subscribing a user</title>
|
2000-06-29 12:11:24 +00:00
|
|
|
<programlisting>
|
2000-07-01 21:36:42 +00:00
|
|
|
$user = "kris@koehntopp.de";
|
|
|
|
$hash = ezmlm_hash ($user);
|
|
|
|
$query = sprintf ("INSERT INTO sample VALUES (%s, '%s')", $hash, $user);
|
|
|
|
$db->query($query); // using PHPLIB db interface
|
2000-06-29 12:11:24 +00:00
|
|
|
</programlisting>
|
2000-07-01 21:36:42 +00:00
|
|
|
</example>
|
|
|
|
</para>
|
2000-06-29 12:11:24 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
</reference>
|
|
|
|
|
2000-07-01 21:36:42 +00:00
|
|
|
<!-- Keep this comment at the end of the file
|
1999-06-06 18:51:02 +00:00
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
sgml-parent-document:nil
|
2000-07-01 03:17:30 +00:00
|
|
|
sgml-default-dtd-file:"../../manual.ced"
|
1999-06-06 18:51:02 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
-->
|