Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

mail.inc.php

Go to the documentation of this file.
00001 <?
00002 require_once("phpmailer/class.phpmailer.php");
00003 
00010 class Mail
00011 {
00015     private static $mailer;
00016     
00020     private function __construct()
00021     {
00022     }
00023     
00035     public static function send($to, $subject, $message, $html = null, $from = null)
00036     {
00037         return self::$mailer->mail($to, $subject, $message, $html, $from);
00038     }
00039 
00045     public static function setMailer(phpmailer $mailer)
00046     {
00047         self::$mailer = $mailer;
00048     }
00049     
00055     public static function getMailer()
00056     {
00057         return self::$mailer;
00058     }
00059 }
00060 
00064 class MyMail extends phpmailer 
00065 { 
00066     // Set default variables for all new objects
00067 
00068     function __construct()
00069     {
00070         $this->Sender   = Config::get('mailer_from');
00071         $this->From     = Config::get('mailer_from');
00072         $this->FromName = Config::get('mailer_from_sender');
00073         $this->Hostname = Config::get('mailer_from_host');
00074         $this->WordWrap = 100;
00075         $this->isMail();
00076     }
00077  
00078     function mail($to, $subject, $message, $html = null, $from = null)
00079     {
00080         if ($from !== null)
00081         {
00082             $this->From = $from;
00083             $this->Sender = $from;
00084         }
00085 
00086         if ($html === null)
00087             $html = nl2br($message);
00088 
00089         $this->ClearAddresses();
00090         $this->ClearAttachments();
00091         
00092         $this->Body = $html;
00093         $this->Subject = $subject;
00094         $this->AltBody = $message;
00095 
00096         if (is_object($to))
00097             $this->AddAddress($to->email, $to->getName());
00098         else
00099             $this->AddAddress($to);
00100 
00101         if(!$this->Send())
00102                 echo "There has been a mail error sending to $to <br/>";
00103     }
00104  
00105     // Replace the default error_handler
00106     function error_handler($msg)
00107     {
00108         throw new Exception("<b>Mail Error: $msg</b>"); 
00109     }
00110 }
00111 
00112 //create our global mailer...
00113 Mail::setMailer(new MyMail());
00114 ?>

Generated on Fri Oct 27 12:26:40 2006 for BaseJumper by doxygen 1.3.9.1