Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezmailnotificationtransport.php
Go to the documentation of this file.
1 <?php
17 class eZMailNotificationTransport extends eZNotificationTransport
18 {
19 function send( $addressList, $subject, $body, $transportData = null, $parameters = array() )
20 {
21 $ini = eZINI::instance();
22 $mail = new eZMail();
23 $addressList = $this->prepareAddressString( $addressList, $mail );
24
25 if ( $addressList == false )
26 {
27 eZDebug::writeError( 'Error with receiver', __METHOD__ );
28 return false;
29 }
30
31 $notificationINI = eZINI::instance( 'notification.ini' );
32 $emailSender = $notificationINI->variable( 'MailSettings', 'EmailSender' );
33 if ( !$emailSender )
34 $emailSender = $ini->variable( 'MailSettings', 'EmailSender' );
35 if ( !$emailSender )
36 $emailSender = $ini->variable( "MailSettings", "AdminEmail" );
37
38 foreach ( $addressList as $addressItem )
39 {
40 $mail->extractEmail( $addressItem, $email, $name );
41 $mail->addReceiver $email, $name );
42 }
43 $mail->setSender( $emailSender );
44 $mail->setSubject( $subject );
45 $mail->setBody( $body );
46 if ( isset( $parameters['message_id'] ) )
47 $mail->addExtraHeader( 'Message-ID', $parameters['message_id'] );
48 if ( isset( $parameters['references'] ) )
49 $mail->addExtraHeader( 'References', $parameters['references'] );
50 if ( isset( $parameters['reply_to'] ) )
51 $mail->addExtraHeader( 'In-Reply-To', $parameters['reply_to'] );
52 if ( isset( $parameters['from'] ) )
53 $mail->setSenderText( $parameters['from'] );
54 if ( isset( $parameters['content_type'] ) )
55 $mail->setContentType( $parameters['content_type'] );
56 $mailResult = eZMailTransport::send( $mail );
57 return $mailResult;
58 }
59
60
61 function prepareAddressString( $addressList, $mail )
62 {
63 if ( is_array( $addressList ) )
64 {
65 $validatedAddressList = array();
66 foreach ( $addressList as $address )
67 {
68 if ( $mail->validate( $address ) )
69 {
70 $validatedAddressList[] = $address;
71 }
72 }
73 // $addressString = '';
74 // if ( count( $validatedAddressList ) > 0 )
75 // {
76 // $addressString = implode( ',', $validatedAddressList );
77 // return $addressString;
78 // }
79 return $validatedAddressList;
80 }
81 else if ( strlen( $addressList ) > 0 )
82 {
83 if ( $mail->validate( $addressList ) )
84 {
85 return $addressList;
86 }
87 }
88 return false;
89 }
90 }
91
92 ?>
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZMailNotificationTransport
The class eZMailNotificationTransport does.
Definition: ezmailnotificationtransport.php:18
eZMailNotificationTransport\prepareAddressString
prepareAddressString( $addressList, $mail)
Definition: ezmailnotificationtransport.php:61
eZMailNotificationTransport\send
send( $addressList, $subject, $body, $transportData=null, $parameters=array())
Definition: ezmailnotificationtransport.php:19
eZMailTransport\send
static send(eZMail $mail)
Definition: ezmailtransport.php:32
eZMail
Mail handler.
Definition: ezmail.php:60
eZNotificationTransport
The class eZNotificationTransport does.
Definition: eznotificationtransport.php:17
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.