|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZMailNotificationTransport class 00004 // 00005 // Created on: <13-May-2003 13:22:20 sp> 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 ezmailnotificationtransport.php 00032 */ 00033 00034 /*! 00035 \class eZMailNotificationTransport ezmailnotificationtransport.php 00036 \brief The class eZMailNotificationTransport does 00037 00038 */ 00039 00040 class eZMailNotificationTransport extends eZNotificationTransport 00041 { 00042 /*! 00043 Constructor 00044 */ 00045 function eZMailNotificationTransport() 00046 { 00047 $this->eZNotificationTransport(); 00048 } 00049 00050 function send( $addressList = array(), $subject, $body, $transportData = null, $parameters = array() ) 00051 { 00052 //include_once( 'lib/ezutils/classes/ezmail.php' ); 00053 //include_once( 'lib/ezutils/classes/ezmailtransport.php' ); 00054 $ini = eZINI::instance(); 00055 $mail = new eZMail(); 00056 $addressList = $this->prepareAddressString( $addressList, $mail ); 00057 00058 if ( $addressList == false ) 00059 { 00060 eZDebug::writeError( 'Error with receiver', 'eZMailNotificationTransport::send()' ); 00061 return false; 00062 } 00063 00064 $notificationINI = eZINI::instance( 'notification.ini' ); 00065 $emailSender = $notificationINI->variable( 'MailSettings', 'EmailSender' ); 00066 if ( !$emailSender ) 00067 $emailSender = $ini->variable( 'MailSettings', 'EmailSender' ); 00068 if ( !$emailSender ) 00069 $emailSender = $ini->variable( "MailSettings", "AdminEmail" ); 00070 00071 foreach ( $addressList as $addressItem ) 00072 { 00073 $mail->extractEmail( $addressItem, $email, $name ); 00074 $mail->addBcc( $email, $name ); 00075 } 00076 $mail->setSender( $emailSender ); 00077 $mail->setSubject( $subject ); 00078 $mail->setBody( $body ); 00079 if ( isset( $parameters['message_id'] ) ) 00080 $mail->addExtraHeader( 'Message-ID', $parameters['message_id'] ); 00081 if ( isset( $parameters['references'] ) ) 00082 $mail->addExtraHeader( 'References', $parameters['references'] ); 00083 if ( isset( $parameters['reply_to'] ) ) 00084 $mail->addExtraHeader( 'In-Reply-To', $parameters['reply_to'] ); 00085 if ( isset( $parameters['from'] ) ) 00086 $mail->setSenderText( $parameters['from'] ); 00087 $mailResult = eZMailTransport::send( $mail ); 00088 return $mailResult; 00089 } 00090 00091 00092 function prepareAddressString( $addressList, $mail ) 00093 { 00094 if ( is_array( $addressList ) ) 00095 { 00096 $validatedAddressList = array(); 00097 foreach ( $addressList as $address ) 00098 { 00099 if ( $mail->validate( $address ) ) 00100 { 00101 $validatedAddressList[] = $address; 00102 } 00103 } 00104 // $addressString = ''; 00105 // if ( count( $validatedAddressList ) > 0 ) 00106 // { 00107 // $addressString = implode( ',', $validatedAddressList ); 00108 // return $addressString; 00109 // } 00110 return $validatedAddressList; 00111 } 00112 else if ( strlen( $addressList ) > 0 ) 00113 { 00114 if ( $mail->validate( $addressList ) ) 00115 { 00116 return $addressList; 00117 } 00118 } 00119 return false; 00120 } 00121 } 00122 00123 ?>