Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Zend_Mail_Transport_Smtp Class Reference
Inheritance diagram for Zend_Mail_Transport_Smtp:
Zend_Mail_Transport_Abstract

Public Member Functions

 __construct ($host='127.0.0.1', Array $config=array())
 
 __destruct ()
 
 setConnection (Zend_Mail_Protocol_Abstract $connection)
 
 getConnection ()
 
 _sendMail ()
 
- Public Member Functions inherited from Zend_Mail_Transport_Abstract
 send (Zend_Mail $mail)
 

Data Fields

 $EOL = "\n"
 
- Data Fields inherited from Zend_Mail_Transport_Abstract
 $body = ''
 
 $boundary = ''
 
 $header = ''
 
 $recipients = ''
 
 $EOL = "\r\n"
 

Protected Member Functions

 _prepareHeaders ($headers)
 
- Protected Member Functions inherited from Zend_Mail_Transport_Abstract
 _sendMail ()
 
 _getHeaders ($boundary)
 
 _prepareHeaders ($headers)
 
 _buildBody ()
 

Protected Attributes

 $_host
 
 $_port
 
 $_name = 'localhost'
 
 $_auth
 
 $_config
 
 $_connection
 
- Protected Attributes inherited from Zend_Mail_Transport_Abstract
 $_headers = array()
 
 $_isMultipart = false
 
 $_mail = false
 
 $_parts = array()
 

Additional Inherited Members

- Static Protected Member Functions inherited from Zend_Mail_Transport_Abstract
static _formatHeader (&$item, $key, $prefix)
 

Detailed Description

Definition at line 51 of file Smtp.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $host = '127.0.0.1',
Array  $config = array() 
)

Constructor.

Parameters
string$hostOPTIONAL (Default: 127.0.0.1)
array | null$configOPTIONAL (Default: null)
Returns
void
Todo:
Someone please make this compatible with the SendMail transport class.

Definition at line 118 of file Smtp.php.

119  {
120  if (isset($config['name'])) {
121  $this->_name = $config['name'];
122  }
123  if (isset($config['port'])) {
124  $this->_port = $config['port'];
125  }
126  if (isset($config['auth'])) {
127  $this->_auth = $config['auth'];
128  }
129 
130  $this->_host = $host;
131  $this->_config = $config;
132  }
$config
Definition: fraud_order.php:17

◆ __destruct()

__destruct ( )

Class destructor to ensure all open connections are closed

Returns
void

Definition at line 140 of file Smtp.php.

141  {
142  if ($this->_connection instanceof Zend_Mail_Protocol_Smtp) {
143  try {
144  $this->_connection->quit();
145  } catch (Zend_Mail_Protocol_Exception $e) {
146  // ignore
147  }
148  $this->_connection->disconnect();
149  }
150  }

Member Function Documentation

◆ _prepareHeaders()

_prepareHeaders (   $headers)
protected

Format and fix headers

Some SMTP servers do not strip BCC headers. Most clients do it themselves as do we.

@access protected

Parameters
array$headers
Returns
void
Exceptions
Zend_Transport_Exception
See also
Zend_Mail_Transport_Exception

Definition at line 228 of file Smtp.php.

229  {
230  if (!$this->_mail) {
234  #require_once 'Zend/Mail/Transport/Exception.php';
235  throw new Zend_Mail_Transport_Exception('_prepareHeaders requires a registered Zend_Mail object');
236  }
237 
238  unset($headers['Bcc']);
239 
240  // Prepare headers
241  parent::_prepareHeaders($headers);
242  }

◆ _sendMail()

_sendMail ( )

Send an email via the SMTP connection protocol

The connection via the protocol adapter is made just-in-time to allow a developer to add a custom adapter if required before mail is sent.

Returns
void
Todo:
Rename this to sendMail, it's a public method...

Definition at line 185 of file Smtp.php.

186  {
187  // If sending multiple messages per session use existing adapter
188  if (!($this->_connection instanceof Zend_Mail_Protocol_Smtp)) {
189  // Check if authentication is required and determine required class
190  $connectionClass = 'Zend_Mail_Protocol_Smtp';
191  if ($this->_auth) {
192  $connectionClass .= '_Auth_' . ucwords($this->_auth);
193  }
194  if (!class_exists($connectionClass)) {
195  #require_once 'Zend/Loader.php';
196  Zend_Loader::loadClass($connectionClass);
197  }
198  $this->setConnection(new $connectionClass($this->_host, $this->_port, $this->_config));
199  $this->_connection->connect();
200  $this->_connection->helo($this->_name);
201  } else {
202  // Reset connection to ensure reliable transaction
203  $this->_connection->rset();
204  }
205 
206  // Set sender email address
207  $this->_connection->mail($this->_mail->getReturnPath());
208 
209  // Set recipient forward paths
210  foreach ($this->_mail->getRecipients() as $recipient) {
211  $this->_connection->rcpt($recipient);
212  }
213 
214  // Issue DATA command to client
215  $this->_connection->data($this->header . Zend_Mime::LINEEND . $this->body);
216  }
static loadClass($class, $dirs=null)
Definition: Loader.php:52
setConnection(Zend_Mail_Protocol_Abstract $connection)
Definition: Smtp.php:160
const LINEEND
Definition: Mime.php:42

◆ getConnection()

getConnection ( )

Gets the connection protocol instance

Returns
Zend_Mail_Protocol|null

Definition at line 171 of file Smtp.php.

172  {
173  return $this->_connection;
174  }

◆ setConnection()

setConnection ( Zend_Mail_Protocol_Abstract  $connection)

Sets the connection protocol instance

Parameters
Zend_Mail_Protocol_Abstract$client
Returns
void

Definition at line 160 of file Smtp.php.

161  {
162  $this->_connection = $connection;
163  }
$connection
Definition: bulk.php:13

Field Documentation

◆ $_auth

$_auth
protected

Definition at line 89 of file Smtp.php.

◆ $_config

$_config
protected

Definition at line 97 of file Smtp.php.

◆ $_connection

$_connection
protected

Definition at line 105 of file Smtp.php.

◆ $_host

$_host
protected

Definition at line 65 of file Smtp.php.

◆ $_name

$_name = 'localhost'
protected

Definition at line 81 of file Smtp.php.

◆ $_port

$_port
protected

Definition at line 73 of file Smtp.php.

◆ $EOL

$EOL = "\n"

Definition at line 58 of file Smtp.php.


The documentation for this class was generated from the following file: