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

Public Member Functions

 __construct ($options=null)
 
 setOptions (array $options)
 
 defaultCallback ($transport)
 
- Public Member Functions inherited from Zend_Mail_Transport_Abstract
 send (Zend_Mail $mail)
 

Protected Member Functions

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

Protected Attributes

 $_path
 
 $_callback
 
- Protected Attributes inherited from Zend_Mail_Transport_Abstract
 $_headers = array()
 
 $_isMultipart = false
 
 $_mail = false
 
 $_parts = array()
 

Additional Inherited Members

- Data Fields inherited from Zend_Mail_Transport_Abstract
 $body = ''
 
 $boundary = ''
 
 $header = ''
 
 $recipients = ''
 
 $EOL = "\r\n"
 
- Static Protected Member Functions inherited from Zend_Mail_Transport_Abstract
static _formatHeader (&$item, $key, $prefix)
 

Detailed Description

Definition at line 40 of file File.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options = null)

Constructor

Parameters
array | Zend_Config$optionsOPTIONAL (Default: null)
Returns
void

Definition at line 62 of file File.php.

63  {
64  if ($options instanceof Zend_Config) {
65  $options = $options->toArray();
66  } elseif (!is_array($options)) {
67  $options = array();
68  }
69 
70  // Making sure we have some defaults to work with
71  if (!isset($options['path'])) {
72  $options['path'] = sys_get_temp_dir();
73  }
74  if (!isset($options['callback'])) {
75  $options['callback'] = array($this, 'defaultCallback');
76  }
77 
78  $this->setOptions($options);
79  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
setOptions(array $options)
Definition: File.php:87

Member Function Documentation

◆ _sendMail()

_sendMail ( )
protected

Saves e-mail message to a file

Returns
void
Exceptions
Zend_Mail_Transport_Exceptionon not writable target directory
Zend_Mail_Transport_Exceptionon file_put_contents() failure

Definition at line 104 of file File.php.

105  {
106  $file = $this->_path . DIRECTORY_SEPARATOR . call_user_func($this->_callback, $this);
107 
108  if (!is_writable(dirname($file))) {
109  #require_once 'Zend/Mail/Transport/Exception.php';
110  throw new Zend_Mail_Transport_Exception(sprintf(
111  'Target directory "%s" does not exist or is not writable',
112  dirname($file)
113  ));
114  }
115 
116  $email = $this->header . $this->EOL . $this->body;
117 
118  if (!file_put_contents($file, $email)) {
119  #require_once 'Zend/Mail/Transport/Exception.php';
120  throw new Zend_Mail_Transport_Exception('Unable to send mail');
121  }
122  }
$email
Definition: details.phtml:13
is_writable($path)
Definition: io.php:25

◆ defaultCallback()

defaultCallback (   $transport)

Default callback for generating filenames

Parameters
Zend_Mail_Transport_FileFile transport instance
Returns
string

Definition at line 130 of file File.php.

131  {
132  return 'ZendMail_' . $_SERVER['REQUEST_TIME'] . '_' . mt_rand() . '.tmp';
133  }

◆ setOptions()

setOptions ( array  $options)

Sets options

Parameters
array$options
Returns
void

Definition at line 87 of file File.php.

88  {
89  if (isset($options['path']) && is_dir($options['path'])) {
90  $this->_path = $options['path'];
91  }
92  if (isset($options['callback']) && is_callable($options['callback'])) {
93  $this->_callback = $options['callback'];
94  }
95  }

Field Documentation

◆ $_callback

$_callback
protected

Definition at line 54 of file File.php.

◆ $_path

$_path
protected

Definition at line 47 of file File.php.


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