[ Index ]

PHP Cross Reference of Akelos Framework

title

Body

[close]

/AkActionMailer/ -> AkMailMessage.php (source)

   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
   3  
   4  // +----------------------------------------------------------------------+
   5  // | Akelos Framework - http://www.akelos.org                             |
   6  // +----------------------------------------------------------------------+
   7  // | Copyright (c) 2002-2006, Akelos Media, S.L.  & Bermi Ferrer Martinez |
   8  // | Released under the GNU Lesser General Public License, see LICENSE.txt|
   9  // +----------------------------------------------------------------------+
  10  
  11  /**
  12   * @package AkelosFramework
  13   * @subpackage AkActionMailer
  14   * @author Bermi Ferrer <bermi a.t akelos c.om>
  15   * @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
  16   * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html>
  17   */
  18  
  19  
  20  require_once (AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailBase.php');
  21  require_once (AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailPart.php');
  22  require_once (AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailParser.php');
  23  require_once (AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailComposer.php');
  24  require_once (AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailEncoding.php');
  25  
  26  class AkMailMessage extends AkMailBase
  27  {
  28  
  29  
  30      /**
  31       * Specify the from address for the message.
  32       */
  33      function setFrom($from)
  34      {
  35          $this->from = $from;
  36      }
  37  
  38      function getFrom()
  39      {
  40          return $this->_getMessageHeaderFieldFormated(!empty($this->from) ? $this->from : @$this->sender);
  41      }
  42  
  43      function getTo()
  44      {
  45          return $this->getRecipients();
  46      }
  47  
  48      function getRecipients()
  49      {
  50          return $this->_getMessageHeaderFieldFormated($this->recipients);
  51      }
  52  
  53      function getBcc()
  54      {
  55          return $this->_getMessageHeaderFieldFormated($this->bcc);
  56      }
  57  
  58      function getCc()
  59      {
  60          return $this->_getMessageHeaderFieldFormated($this->cc);
  61      }
  62  
  63      function setTo($to)
  64      {
  65          $this->setRecipients($to);
  66      }
  67  
  68      function setDate($date = null, $validate = true)
  69      {
  70          $date = trim($date);
  71          $is_valid =  preg_match("/^".AK_ACTION_MAILER_RFC_2822_DATE_REGULAR_EXPRESSION."$/",$date);
  72          $date = !$is_valid ? date('r', (empty($date) ? Ak::time() : (!is_numeric($date) ? strtotime($date) : $date))) : $date;
  73  
  74          if($validate && !$is_valid  && !preg_match("/^".AK_ACTION_MAILER_RFC_2822_DATE_REGULAR_EXPRESSION."$/",$date)){
  75              trigger_error(Ak::t('You need to supply a valid RFC 2822 date. You can just leave the date field blank or pass a timestamp and Akelos will automatically format the date for you'), E_USER_ERROR);
  76          }
  77  
  78          $this->date = $date;
  79      }
  80  
  81      function setSentOn($date)
  82      {
  83          $this->setDate($date);
  84      }
  85  
  86      function setReturnPath($return_path)
  87      {
  88          $this->returnPath = $return_path;
  89      }
  90  
  91      /**
  92       * Defaults to "1.0", but may be explicitly given if needed.
  93       */
  94      function setMimeVersion($mime_version = null)
  95      {
  96          $this->mime_version = empty($mime_version) ? ((empty($this->mime_version) && !empty($this->parts)) ? '1.0' : $this->mime_version) : $mime_version;
  97      }
  98  
  99      /**
 100       * The recipient addresses for the message, either as a string (for a single
 101       * address) or an array (for multiple addresses).
 102       */
 103      function setRecipients($recipients)
 104      {
 105          $this->recipients = $this->_getMessageHeaderFieldFormated($recipients);
 106          $this->setHeader('To',$this->getTo());
 107      }
 108  
 109      /**
 110       * Specify the subject of the message.
 111       */
 112      function setSubject($subject)
 113      {
 114          $this->subject = $subject;
 115      }
 116  
 117      function getSubject($charset = null)
 118      {
 119          $charset = empty($charset) ? $this->getCharset() : $charset;
 120          return AkActionMailerQuoting::quoteIfNecessary($this->subject, $charset);
 121      }
 122  
 123      function _getMessageHeaderFieldFormated($address_header_field)
 124      {
 125          $charset = empty($this->charset) ? AK_ACTION_MAILER_DEFAULT_CHARSET : $this->charset;
 126          return AkActionMailerQuoting::quoteAddressIfNecessary($address_header_field, $charset);
 127      }
 128  
 129  
 130      function getRawMessage()
 131      {
 132          return AkMailComposer::getRawMessage($this);
 133      }
 134  
 135      function getRawHeadersAndBody()
 136      {
 137          $Composer =& new AkMailComposer();
 138          return $Composer->getRawHeadersAndBody($this);
 139      }
 140  }
 141  
 142  
 143  ?>


Generated: Mon Oct 27 12:43:49 2008 Cross-referenced by PHPXref 0.6