eZ Publish  [4.0]
ezmailtransport.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZMailTransport class
00004 //
00005 // Created on: <10-Dec-2002 14:31:35 amos>
00006 //
00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00008 // SOFTWARE NAME: eZ Publish
00009 // SOFTWARE RELEASE: 4.0.x
00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00011 // SOFTWARE LICENSE: GNU General Public License v2.0
00012 // NOTICE: >
00013 //   This program is free software; you can redistribute it and/or
00014 //   modify it under the terms of version 2.0  of the GNU General
00015 //   Public License as published by the Free Software Foundation.
00016 //
00017 //   This program is distributed in the hope that it will be useful,
00018 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //   GNU General Public License for more details.
00021 //
00022 //   You should have received a copy of version 2.0 of the GNU General
00023 //   Public License along with this program; if not, write to the Free
00024 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 //   MA 02110-1301, USA.
00026 //
00027 //
00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00029 //
00030 
00031 /*! \file ezmailtransport.php
00032 */
00033 
00034 /*!
00035   \class eZMailTransport ezmailtransport.php
00036   \brief Interface for mail transport handling
00037 
00038 */
00039 
00040 class eZMailTransport
00041 {
00042     /*!
00043      Constructor
00044     */
00045     function eZMailTransport()
00046     {
00047     }
00048 
00049     /*!
00050      \virtual
00051      Tries to send the contents of the email object \a $mail and
00052      returns \c true if succesful.
00053     */
00054     function sendMail( eZMail $mail )
00055     {
00056         return false;
00057     }
00058 
00059     /*!
00060      \static
00061      Sends the contents of the email object \a $mail using the default transport.
00062     */
00063     static function send( eZMail $mail )
00064     {
00065         $ini = eZINI::instance();
00066 
00067         $transportType = trim( $ini->variable( 'MailSettings', 'Transport' ) );
00068         $globalsKey = 'eZMailTransportHandler_' . strtolower( $transportType );
00069         if ( !isset( $GLOBALS[$globalsKey] ) ||
00070              !( $GLOBALS[$globalsKey] instanceof eZMailTransport ) )
00071         {
00072             $transportClassFile = 'ez' . strtolower( $transportType ) . 'transport.php';
00073             $transportClassPath = 'lib/ezutils/classes/' . $transportClassFile;
00074             $transportClass = 'eZ' . $transportType . 'Transport';
00075             if ( !file_exists( $transportClassPath ) )
00076             {
00077                 eZDebug::writeError( "Unknown mail transport type '$transportType', cannot send mail",
00078                                      'eZMailTransport::send' );
00079                 return false;
00080             }
00081             include_once( $transportClassPath );
00082             if ( !class_exists( $transportClass ) )
00083             {
00084                 eZDebug::writeError( "No class available for mail transport type '$transportType', cannot send mail",
00085                                      'eZMailTransport::send' );
00086                 return false;
00087             }
00088             $GLOBALS[$globalsKey] = new $transportClass();
00089         }
00090         return $GLOBALS[$globalsKey]->sendMail( $mail );
00091     }
00092 }
00093 
00094 ?>