eZ Publish  [trunk]
ezfiletransport.php
Go to the documentation of this file.
00001 <?php
00002 /**
00003  * File containing the eZFileTransport class.
00004  *
00005  * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
00006  * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
00007  * @version //autogentag//
00008  * @package lib
00009  */
00010 
00011 /*!
00012   \class eZFileTransport ezfiletransport.php
00013   \brief Sends the email message to a file.
00014 
00015 */
00016 
00017 class eZFileTransport extends eZMailTransport
00018 {
00019     /*!
00020      Constructor
00021     */
00022     function eZFileTransport()
00023     {
00024     }
00025 
00026     function sendMail( eZMail $mail )
00027     {
00028         $ini = eZINI::instance();
00029         $sendmailOptions = '';
00030         $emailFrom = $mail->sender();
00031         $emailSender = $emailFrom['email'];
00032         if ( !$emailSender || count( $emailSender) <= 0 )
00033             $emailSender = $ini->variable( 'MailSettings', 'EmailSender' );
00034         if ( !$emailSender )
00035             $emailSender = $ini->variable( 'MailSettings', 'AdminEmail' );
00036         if ( !eZMail::validate( $emailSender ) )
00037             $emailSender = false;
00038 
00039         $isSafeMode = ini_get( 'safe_mode' );
00040         if ( $isSafeMode and
00041              $emailSender and
00042              $mail->sender() == false )
00043             $mail->setSenderText( $emailSender );
00044 
00045         $filename = time() . '-' . mt_rand() . '.mail';
00046 
00047         $data = preg_replace('/(\r\n|\r|\n)/', "\r\n", $mail->headerText() . "\n" . $mail->body() );
00048         $returnedValue = eZFile::create( $filename, 'var/log/mail', $data );
00049         if ( $returnedValue === false )
00050         {
00051             eZDebug::writeError( 'An error occurred writing the e-mail file in var/log/mail', __METHOD__ );
00052         }
00053 
00054         return $returnedValue;
00055     }
00056 }
00057 
00058 ?>