eZ Publish  [4.0]
ezfiletransport.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZFileTransport class
00004 //
00005 // Created on: <10-Dec-2002 14:41:22 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 ezsendmailtransport.php
00032 */
00033 
00034 /*!
00035   \class eZFileTransport ezfiletransport.php
00036   \brief Sends the email message to a file.
00037 
00038 */
00039 
00040 //include_once( 'lib/ezutils/classes/ezmailtransport.php' );
00041 //include_once( 'lib/ezfile/classes/ezfile.php' );
00042 
00043 class eZFileTransport extends eZMailTransport
00044 {
00045     /*!
00046      Constructor
00047     */
00048     function eZFileTransport()
00049     {
00050     }
00051 
00052     /*!
00053      \reimp
00054     */
00055     function sendMail( eZMail $mail )
00056     {
00057         $ini = eZINI::instance();
00058         $sendmailOptions = '';
00059         $emailFrom = $mail->sender();
00060         $emailSender = $emailFrom['email'];
00061         if ( !$emailSender || count( $emailSender) <= 0 )
00062             $emailSender = $ini->variable( 'MailSettings', 'EmailSender' );
00063         if ( !$emailSender )
00064             $emailSender = $ini->variable( 'MailSettings', 'AdminEmail' );
00065         if ( !eZMail::validate( $emailSender ) )
00066             $emailSender = false;
00067 
00068         $isSafeMode = ini_get( 'safe_mode' );
00069         if ( $isSafeMode and
00070              $emailSender and
00071              $mail->sender() == false )
00072             $mail->setSenderText( $emailSender );
00073 
00074         $filename = time() . '-' . rand() . '.mail';
00075 
00076         $data = preg_replace('/(\r\n|\r|\n)/', "\r\n", $mail->headerText() . "\n" . $mail->body() );
00077         $returnedValue = eZFile::create( $filename, 'var/log/mail', $data );
00078         if ( $returnedValue === false )
00079         {
00080             eZDebug::writeError( 'An error occurred writing the e-mail file in var/log/mail', __METHOD__ );
00081         }
00082 
00083         return $returnedValue;
00084     }
00085 }
00086 
00087 ?>