Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezsmtptransport.php
Go to the documentation of this file.
1 <?php
17 class eZSMTPTransport extends eZMailTransport
18 {
19 function sendMail( eZMail $mail )
20 {
21 $ini = eZINI::instance();
22 $parameters = array();
23 $parameters['host'] = $ini->variable( 'MailSettings', 'TransportServer' );
24 $parameters['helo'] = $ini->variable( 'MailSettings', 'SenderHost' );
25 $parameters['port'] = $ini->variable( 'MailSettings', 'TransportPort' );
26 $parameters['connectionType'] = $ini->variable( 'MailSettings', 'TransportConnectionType' );
27 $user = $ini->variable( 'MailSettings', 'TransportUser' );
28 $password = $ini->variable( 'MailSettings', 'TransportPassword' );
29 if ( $user and
30 $password )
31 {
32 $parameters['auth'] = true;
33 $parameters['user'] = $user;
34 $parameters['pass'] = $password;
35 }
36
37 /* If email sender hasn't been specified or is empty
38 * we substitute it with either MailSettings.EmailSender or AdminEmail.
39 */
40 if ( !$mail->senderText() )
41 {
42 $emailSender = $ini->variable( 'MailSettings', 'EmailSender' );
43 if ( !$emailSender )
44 $emailSender = $ini->variable( 'MailSettings', 'AdminEmail' );
45
46 eZMail::extractEmail( $emailSender, $emailSenderAddress, $emailSenderName );
47
48 if ( !eZMail::validate( $emailSenderAddress ) )
49 $emailSender = false;
50
51 if ( $emailSender )
52 $mail->setSenderText( $emailSender );
53 }
54
55 $excludeHeaders = $ini->variable( 'MailSettings', 'ExcludeHeaders' );
56 if ( count( $excludeHeaders ) > 0 )
57 $mail->Mail->appendExcludeHeaders( $excludeHeaders );
58
59 $options = new ezcMailSmtpTransportOptions();
60 if( $parameters['connectionType'] )
61 {
62 $options->connectionType = $parameters['connectionType'];
63 }
64 $smtp = new ezcMailSmtpTransport( $parameters['host'], $user, $password,
65 $parameters['port'], $options );
66
67 // If in debug mode, send to debug email address and nothing else
68 if ( $ini->variable( 'MailSettings', 'DebugSending' ) == 'enabled' )
69 {
70 $mail->Mail->to = array( new ezcMailAddress( $ini->variable( 'MailSettings', 'DebugReceiverEmail' ) ) );
71 $mail->Mail->cc = array();
72 $mail->Mail->bcc = array();
73 }
74
75 // send() from ezcMailSmtpTransport doesn't return anything (it uses exceptions in case
76 // something goes bad)
77 try
78 {
79 $smtp->send( $mail->Mail );
80 }
81 catch ( ezcMailException $e )
82 {
83 eZDebug::writeError( $e->getMessage(), __METHOD__ );
84 return false;
85 }
86
87 // return true in case of no exceptions
88 return true;
89 }
90 }
91
92 ?>
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZMailTransport
Interface for mail transport handling.
Definition: ezmailtransport.php:18
eZMail
Mail handler.
Definition: ezmail.php:60
eZMail\senderText
senderText( $convert=true)
Definition: ezmail.php:278
eZMail\setSenderText
setSenderText( $text)
Definition: ezmail.php:499
eZMail\extractEmail
static extractEmail( $text, &$email, &$name)
Definition: ezmail.php:757
eZMail\validate
static validate( $address)
Definition: ezmail.php:747
eZSMTPTransport
The class eZSMTPTransport does.
Definition: ezsmtptransport.php:18
eZSMTPTransport\sendMail
sendMail(eZMail $mail)
Definition: ezsmtptransport.php:19
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.