PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / libs / Zend / Mail / Transport / File.php
matomo / app / libs / Zend / Mail / Transport Last commit date
Abstract.php 6 years ago Exception.php 6 years ago File.php 6 years ago Sendmail.php 6 years ago Smtp.php 6 years ago
File.php
135 lines
1 <?php
2 /**
3 * Zend Framework
4 *
5 * LICENSE
6 *
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
14 *
15 * @category Zend
16 * @package Zend_Mail
17 * @subpackage Transport
18 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id$
21 */
22
23 /**
24 * @see Zend_Mail_Transport_Abstract
25 */
26 // require_once 'Zend/Mail/Transport/Abstract.php';
27
28
29 /**
30 * File transport
31 *
32 * Class for saving outgoing emails in filesystem
33 *
34 * @category Zend
35 * @package Zend_Mail
36 * @subpackage Transport
37 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
38 * @license http://framework.zend.com/license/new-bsd New BSD License
39 */
40 class Zend_Mail_Transport_File extends Zend_Mail_Transport_Abstract
41 {
42 /**
43 * Target directory for saving sent email messages
44 *
45 * @var string
46 */
47 protected $_path;
48
49 /**
50 * Callback function generating a file name
51 *
52 * @var string|array
53 */
54 protected $_callback;
55
56 /**
57 * Constructor
58 *
59 * @param array|Zend_Config $options OPTIONAL (Default: null)
60 * @return void
61 */
62 public function __construct($options = null)
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 }
80
81 /**
82 * Sets options
83 *
84 * @param array $options
85 * @return void
86 */
87 public function setOptions(array $options)
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 }
96
97 /**
98 * Saves e-mail message to a file
99 *
100 * @return void
101 * @throws Zend_Mail_Transport_Exception on not writable target directory
102 * @throws Zend_Mail_Transport_Exception on file_put_contents() failure
103 */
104 protected function _sendMail()
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 }
123
124 /**
125 * Default callback for generating filenames
126 *
127 * @param Zend_Mail_Transport_File File transport instance
128 * @return string
129 */
130 public function defaultCallback($transport)
131 {
132 return 'ZendMail_' . $_SERVER['REQUEST_TIME'] . '_' . mt_rand() . '.tmp';
133 }
134 }
135