home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 March / PCWorld_2003-03_cd.bin / Software / Vyzkuste / phptriad / phptriad2-2-1.exe / php / pear / Mail / mail.php next >
Encoding:
PHP Script  |  2001-08-09  |  3.2 KB  |  77 lines

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4.0                                                      |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2001 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Chuck Hagenbuch <chuck@horde.org>                           |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: mail.php,v 1.2 2001/08/09 00:53:56 alexmerz Exp $
  20.  
  21. require_once ('Mail.php');
  22.  
  23. /**
  24.  * internal PHP-mail() implementation of the PEAR Mail:: interface.
  25.  * @access public
  26.  * @package Mail
  27.  * @version $Revision: 1.2 $
  28.  */
  29.  
  30.  class Mail_mail extends Mail {
  31.     /**
  32.      * Implements Mail_mail::send() function using php's built-in mail()
  33.      * command.
  34.      * 
  35.      * @param mixed $recipients Either a comma-seperated list of recipients
  36.      *              (RFC822 compliant), or an array of recipients,
  37.      *              each RFC822 valid. This may contain recipients not
  38.      *              specified in the headers, for Bcc:, resending
  39.      *              messages, etc.
  40.      *
  41.      * @param array $headers The array of headers to send with the mail, in an
  42.      *              associative array, where the array key is the
  43.      *              header name (ie, 'Subject'), and the array value
  44.      *              is the header value (ie, 'test'). The header
  45.      *              produced from those values would be 'Subject:
  46.      *              test'.
  47.      *
  48.      * @param string $body The full text of the message body, including any
  49.      *               Mime parts, etc.
  50.      *
  51.      * @return mixed Returns true on success, or a PEAR_Error
  52.      *               containing a descriptive error message on
  53.      *               failure.
  54.      * @access public
  55.      */    
  56.     function send($recipients, $headers, $body)
  57.     {
  58.         // if we're passed an array of recipients, implode it.
  59.         if (is_array($recipients)) {
  60.             $recipients = implode(', ', $recipients);
  61.         }
  62.         
  63.         // get the Subject out of the headers array so that we can
  64.         // pass it as a seperate argument to mail().
  65.         $subject = '';
  66.         if (isset($headers['Subject'])) {
  67.             $subject = $headers['Subject'];
  68.             unset($headers['Subject']);
  69.         }
  70.         
  71.         // flatten the headers out.
  72.         list(,$text_headers) = Mail::prepareHeaders($headers);
  73.         
  74.         return mail($recipients, $subject, $body, $text_headers);
  75.     }
  76.     
  77. }