Source for file Mail.php

Documentation is available at Mail.php

  1. <?php
  2. /**
  3.  *    LAIKA FRAMEWORK Release Notes:
  4.  *
  5.  *    @filesource     Mail.php
  6.  *
  7.  *    @version        0.1.0b
  8.  *    @package        Laika
  9.  *    @subpackage     util
  10.  *    @category
  11.  *    @date           2012-05-18 22:10:23 -0400 (Fri, 18 May 2012)
  12.  *
  13.  *    @author         Leonard M. Witzel <witzel@post.harvard.edu>
  14.  *    @copyright      Copyright (c) 2012  Laika Soft <{@link http://oafbot.com}>
  15.  *
  16.  */
  17. /**
  18.  * Laika_Mail class.
  19.  * 
  20.  * @extends Laika
  21.  */
  22. class Laika_Mail extends Laika{
  23.  
  24. /*
  25.     private $sender;
  26.     private $recipient;
  27.     private $subject;
  28.     private $message;
  29. */
  30.  
  31.     /**
  32.      * sendmail function.
  33.      * 
  34.      * @access public
  35.      * @static
  36.      * @param mixed  $users 
  37.      * @param string $subject 
  38.      * @param string $message 
  39.      * @param array  $head 
  40.      * @return void 
  41.      */
  42.     public static function sendmail($users,$subject,$message,$head){
  43.         $recipient self::set_recipients($users);
  44.         $headers self::set_headers($head);                
  45.         mail($recipient$subject$message ,$headers);
  46.     }
  47.     
  48.     /**
  49.      * set_headers function.
  50.      * 
  51.      * @access public
  52.      * @static
  53.      * @param array $array 
  54.      * @return void 
  55.      */
  56.     public static function set_headers($array){
  57.         $headers='';
  58.         foreach($array as $key => $value){
  59.             switch($key){
  60.                 case 'SENDER':
  61.                     $headers .= "From: $value\n";
  62.                     break;
  63.                 case 'CC':
  64.                     $headers .= "Cc: $value\n";
  65.                     break;
  66.                 case 'BCC':
  67.                     $headers .= "Bcc: $bcc\n";
  68.                     break;
  69.                 case 'FORMAT':
  70.                     $headers .= "Content-type: text/$value; charset=utf-8\n";
  71.                     $headers .= "MIME-Version: 1.0\n";
  72.                     $headers .="Content-Transfer-Encoding: 8bit\n";
  73.                     break;
  74.                 case 'MIME':
  75.                     $headers .= "MIME-Version: $value\n"//1.0
  76.                     break;
  77.                 case 'ENCODING':
  78.                     $headers .="Content-Transfer-Encoding: $value\n"//8bit charset=ISO-8859-1
  79.                     break;       
  80.             }
  81.         }
  82.         return $headers;
  83.     }
  84.     
  85.     /**
  86.      * set_recipients function.
  87.      * 
  88.      * @access public
  89.      * @static
  90.      * @param mixed $users 
  91.      * @return void 
  92.      */
  93.     public static function set_recipients($users){
  94.         if(is_array($users))
  95.             foreach($users as $key => $user):
  96.                 if($key>0)
  97.                     $recepient .= ',';
  98.                 $recipient .= $user->firstname().' '.$user->lastname().'<'.$user->email().'>';
  99.             endforeach;
  100.         else
  101.             $recipient $users->firstname().' '.$users->lastname().'<'.$users->email().'>';
  102.         
  103.         return $recipient;               
  104.     }
  105.     
  106.     /**
  107.      * load_template function.
  108.      * 
  109.      * @access public
  110.      * @static
  111.      * @param string $template 
  112.      * @param array  $params 
  113.      * @return void 
  114.      */
  115.     public static function load_template($template,$params){
  116.         foreach($params as $key => $value)
  117.             $$key $value;
  118.         include_once($template);
  119.         
  120.         return $content;        
  121.     }
  122. }

Documentation generated on Sat, 19 May 2012 02:17:02 -0400 by phpDocumentor 1.4.4