cvs: peardoc /en/core mail.xml
| From: | Richard Heyes | Date: | Sat, 09 Feb 2002 11:22:14 +0000 |
| Subject: | cvs: peardoc /en/core mail.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-2340@lists.php.net to get a copy of this message | ||
heyesr Sat Feb 9 06:22:14 2002 EDT
Modified files:
/peardoc/en/core mail.xml
Log:
* Added Mail::RFC822 docs
Index: peardoc/en/core/mail.xml
diff -u peardoc/en/core/mail.xml:1.3 peardoc/en/core/mail.xml:1.4
--- peardoc/en/core/mail.xml:1.3 Tue Jan 8 08:13:53 2002
+++ peardoc/en/core/mail.xml Sat Feb 9 06:22:13 2002
@@ -1,5 +1,5 @@
<?xml encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<reference id="core.mail">
<title>PEAR Mail: Mail handling functions</title>
@@ -762,6 +762,163 @@
</programlisting>
</para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="core.mail.RFC822">
+ <refnamediv>
+ <refname>Mail/RFC822.php</refname>
+ <refpurpose>Provides RFC822 compliant email address parsing</refpurpose>
+ </refnamediv>
+
+ <refsect1>
+ <title>Description</title>
+ <simpara>
+ This class performs email address checking to the RFC822 specification.
+ This is not a simple task, hence why this class is so large. It returns
+ an array of objects, each pertaining to one of the input addresses. The
+ objects have these properties:
+ </simpara>
+
+ <para>
+ <emphasis>personal:</emphasis> This is the "personal" part of the email
+ address. For example, in the email address: "Richard Heyes"
<heyesr@php.net>
+ the personal part would be "Richard Heyes".
+ </para>
+
+ <para>
+ <emphasis>comment:</emphasis> Any comments in the email address, will be
+ in this array.
+ </para>
+
+ <para>
+ <emphasis>mailbox:</emphasis> This is the portion of the email which is
+ on the left hand side of the @. In the example email above, the mailbox
+ would be heyesr.
+ </para>
+
+ <para>
+ <emphasis>host:</emphasis> This is the portion of the email which is on
+ the right hand side of the @. In the example above, the host would be php.net.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>Groups</title>
+ <simpara>
+ The structure of the returned objects is slightly different if the address
+ contains rfc822 groups. In this case, the returned objects have these properties:
+ </simpara>
+
+ <para>
+ <emphasis>groupname</emphasis> This is the name of the group. In this address:
+ My Group: address1@host.com, address2@host.com; the groupname would be "My Group"
+ (no quotes).
+ </para>
+
+ <para>
+ <emphasis>addresses</emphasis> This is an array of address objects which have
+ the same properties as described above.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title><function>Mail_RFC822::constructor</function></title>
+ <simpara>
+ This takes the following four arguments:
+ </simpara>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <parameter>$address</parameter> - The address(es) to validate
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <parameter>$default_domain</parameter> - The default domain to use in
+ case of absence
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <parameter>$nest_groups</parameter> - Whether to nest groups or not.
+ If FALSE, groups will not be nested and group names will be lost
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <parameter>$validate</parameter> - Whether to validate atoms. Turn
+ this off if you need to run addresses through before encoding the personal
+ names, for instance
+ </para>
+ </listitem>
+ </itemizedlist>
+ </refsect1>
+
+ <refsect1>
+ <title><function>Mail_RFC822::parseAddressList()</function></title>
+ <simpara>
+ This method should be called to run the validation, and returns the structure
+ detailed above. In can take four arguments, which are the same as the constructor.
+ This method can be called statically, in which case at least the address argument
+ needs to be given.
+ </simpara>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <parameter>$address</parameter> - The address(es) to validate
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <parameter>$default_domain</parameter> - The default domain to use in
case
+ of absence
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <parameter>$nest_groups</parameter> - Whether to nest groups or not. If
+ FALSE, groups will not be nested and group names will be lost
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <parameter>$validate</parameter> - Whether to validate atoms. Turn this
+ off if you need to run addresses through before encoding the personal names,
+ for instance
+ </para>
+ </listitem>
+ </itemizedlist>
+ </refsect1>
+
+ <refsect1>
+ <title>Usage examples:</title>
+ <simpara>
+ This example instanciates an object, calls the validation method parseAddressList()
+ and then prints the results:
+ </simpara>
+ <programlisting role="php">
+ <![CDATA[
+$address = 'My group: "Richard Heyes" <richard@localhost>;, ted@phpguru.org (A
comment)';
+$rfc822 = new Mail_RFC822($address, 'phpguru.org', TRUE);
+
+$addresses = $rfc822->parseAddressList();
+print_r($addresses);
+ ]]>
+ </programlisting>
+
+ <simpara>
+ This example produces the same results as above except that it calls the
+ parseAddressList() method statically:
+ </simpara>
+ <programlisting role="php">
+ <![CDATA[
+$address = 'My group: "Richard Heyes" <richard@localhost>;, ted@phpguru.org (A
comment)';
+
+$addresses = Mail_RFC822::parseAddressList($address, 'phpguru.org', TRUE);
+print_r($addresses);
+ ]]>
+ </programlisting>
</refsect1>
</refentry>
</reference>