equal
deleted
inserted
replaced
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Application |
16 * @package Zend_Application |
17 * @subpackage Resource |
17 * @subpackage Resource |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: Mail.php 21015 2010-02-11 01:56:02Z freak $ |
20 * @version $Id: Mail.php 24593 2012-01-05 20:35:02Z matthew $ |
21 */ |
21 */ |
22 |
22 |
23 /** |
23 /** |
24 * @see Zend_Application_Resource_ResourceAbstract |
24 * @see Zend_Application_Resource_ResourceAbstract |
25 */ |
25 */ |
30 * |
30 * |
31 * @uses Zend_Application_Resource_ResourceAbstract |
31 * @uses Zend_Application_Resource_ResourceAbstract |
32 * @category Zend |
32 * @category Zend |
33 * @package Zend_Application |
33 * @package Zend_Application |
34 * @subpackage Resource |
34 * @subpackage Resource |
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
35 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
37 */ |
37 */ |
38 class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceAbstract |
38 class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceAbstract |
39 { |
39 { |
40 |
40 |
44 protected $_transport; |
44 protected $_transport; |
45 |
45 |
46 public function init() { |
46 public function init() { |
47 return $this->getMail(); |
47 return $this->getMail(); |
48 } |
48 } |
49 |
49 |
50 /** |
50 /** |
51 * |
51 * |
52 * @return Zend_Mail_Transport_Abstract|null |
52 * @return Zend_Mail_Transport_Abstract|null |
53 */ |
53 */ |
54 public function getMail() |
54 public function getMail() |
55 { |
55 { |
56 if (null === $this->_transport) { |
56 if (null === $this->_transport) { |
57 $options = $this->getOptions(); |
57 $options = $this->getOptions(); |
58 foreach($options as $key => $option) { |
58 foreach($options as $key => $option) { |
59 $options[strtolower($key)] = $option; |
59 $options[strtolower($key)] = $option; |
60 } |
60 } |
61 $this->setOptions($options); |
61 $this->setOptions($options); |
62 |
62 |
63 if(isset($options['transport']) && |
63 if(isset($options['transport']) && |
64 !is_numeric($options['transport'])) |
64 !is_numeric($options['transport'])) |
71 (bool) $options['transport']['register'] == true)) |
71 (bool) $options['transport']['register'] == true)) |
72 { |
72 { |
73 Zend_Mail::setDefaultTransport($this->_transport); |
73 Zend_Mail::setDefaultTransport($this->_transport); |
74 } |
74 } |
75 } |
75 } |
76 |
76 |
77 $this->_setDefaults('from'); |
77 $this->_setDefaults('from'); |
78 $this->_setDefaults('replyTo'); |
78 $this->_setDefaults('replyTo'); |
79 } |
79 } |
80 |
80 |
81 return $this->_transport; |
81 return $this->_transport; |
82 } |
82 } |
83 |
83 |
84 protected function _setDefaults($type) { |
84 protected function _setDefaults($type) { |
85 $key = strtolower('default' . $type); |
85 $key = strtolower('default' . $type); |
86 $options = $this->getOptions(); |
86 $options = $this->getOptions(); |
87 |
87 |
88 if(isset($options[$key]['email']) && |
88 if(isset($options[$key]['email']) && |
97 } else { |
97 } else { |
98 call_user_func($method, $options[$key]['email']); |
98 call_user_func($method, $options[$key]['email']); |
99 } |
99 } |
100 } |
100 } |
101 } |
101 } |
102 |
102 |
103 protected function _setupTransport($options) |
103 protected function _setupTransport($options) |
104 { |
104 { |
105 if(!isset($options['type'])) { |
105 if(!isset($options['type'])) { |
106 $options['type'] = 'sendmail'; |
106 $options['type'] = 'sendmail'; |
107 } |
107 } |
108 |
108 |
109 $transportName = $options['type']; |
109 $transportName = $options['type']; |
110 if(!Zend_Loader_Autoloader::autoload($transportName)) |
110 if(!Zend_Loader_Autoloader::autoload($transportName)) |
111 { |
111 { |
112 $transportName = ucfirst(strtolower($transportName)); |
112 $transportName = ucfirst(strtolower($transportName)); |
113 |
113 |
120 . 'could not be found' |
120 . 'could not be found' |
121 ); |
121 ); |
122 } |
122 } |
123 } |
123 } |
124 } |
124 } |
125 |
125 |
126 unset($options['type']); |
126 unset($options['type']); |
127 |
127 unset($options['register']); //@see ZF-11022 |
|
128 |
128 switch($transportName) { |
129 switch($transportName) { |
129 case 'Zend_Mail_Transport_Smtp': |
130 case 'Zend_Mail_Transport_Smtp': |
130 if(!isset($options['host'])) { |
131 if(!isset($options['host'])) { |
131 throw new Zend_Application_Resource_Exception( |
132 throw new Zend_Application_Resource_Exception( |
132 'A host is necessary for smtp transport,' |
133 'A host is necessary for smtp transport,' |
133 .' but none was given'); |
134 .' but none was given'); |
134 } |
135 } |
135 |
136 |
136 $transport = new $transportName($options['host'], $options); |
137 $transport = new $transportName($options['host'], $options); |
137 break; |
138 break; |
138 case 'Zend_Mail_Transport_Sendmail': |
139 case 'Zend_Mail_Transport_Sendmail': |
139 default: |
140 default: |
140 $transport = new $transportName($options); |
141 $transport = new $transportName($options); |