|
|
@@ -43,7 +43,8 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
|
|
|
*/
|
|
|
protected $_transport;
|
|
|
|
|
|
- public function init() {
|
|
|
+ public function init()
|
|
|
+ {
|
|
|
return $this->getMail();
|
|
|
}
|
|
|
|
|
|
@@ -55,21 +56,21 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
|
|
|
{
|
|
|
if (null === $this->_transport) {
|
|
|
$options = $this->getOptions();
|
|
|
- foreach($options as $key => $option) {
|
|
|
+ foreach ($options as $key => $option) {
|
|
|
$options[strtolower($key)] = $option;
|
|
|
}
|
|
|
$this->setOptions($options);
|
|
|
|
|
|
- if(isset($options['transport']) &&
|
|
|
- !is_numeric($options['transport']))
|
|
|
- {
|
|
|
+ if (isset($options['transport'])
|
|
|
+ && !is_numeric($options['transport'])
|
|
|
+ ) {
|
|
|
$this->_transport = $this->_setupTransport($options['transport']);
|
|
|
- if(!isset($options['transport']['register']) ||
|
|
|
- $options['transport']['register'] == '1' ||
|
|
|
- (isset($options['transport']['register']) &&
|
|
|
- !is_numeric($options['transport']['register']) &&
|
|
|
- (bool) $options['transport']['register'] == true))
|
|
|
- {
|
|
|
+ if (!isset($options['transport']['register'])
|
|
|
+ || $options['transport']['register'] == '1'
|
|
|
+ || (isset($options['transport']['register'])
|
|
|
+ && !is_numeric($options['transport']['register'])
|
|
|
+ && (bool)$options['transport']['register'] == true)
|
|
|
+ ) {
|
|
|
Zend_Mail::setDefaultTransport($this->_transport);
|
|
|
}
|
|
|
}
|
|
|
@@ -81,19 +82,23 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
|
|
|
return $this->_transport;
|
|
|
}
|
|
|
|
|
|
- protected function _setDefaults($type) {
|
|
|
+ protected function _setDefaults($type)
|
|
|
+ {
|
|
|
$key = strtolower('default' . $type);
|
|
|
$options = $this->getOptions();
|
|
|
|
|
|
- if(isset($options[$key]['email']) &&
|
|
|
- !is_numeric($options[$key]['email']))
|
|
|
- {
|
|
|
+ if (isset($options[$key]['email'])
|
|
|
+ && !is_numeric($options[$key]['email'])
|
|
|
+ ) {
|
|
|
$method = array('Zend_Mail', 'setDefault' . ucfirst($type));
|
|
|
- if(isset($options[$key]['name']) &&
|
|
|
- !is_numeric($options[$key]['name']))
|
|
|
- {
|
|
|
- call_user_func($method, $options[$key]['email'],
|
|
|
- $options[$key]['name']);
|
|
|
+ if (isset($options[$key]['name'])
|
|
|
+ && !is_numeric(
|
|
|
+ $options[$key]['name']
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ call_user_func(
|
|
|
+ $method, $options[$key]['email'], $options[$key]['name']
|
|
|
+ );
|
|
|
} else {
|
|
|
call_user_func($method, $options[$key]['email']);
|
|
|
}
|
|
|
@@ -102,19 +107,17 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
|
|
|
|
|
|
protected function _setupTransport($options)
|
|
|
{
|
|
|
- if(!isset($options['type'])) {
|
|
|
+ if (!isset($options['type'])) {
|
|
|
$options['type'] = 'sendmail';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$transportName = $options['type'];
|
|
|
- if(!Zend_Loader_Autoloader::autoload($transportName))
|
|
|
- {
|
|
|
+ if (!Zend_Loader_Autoloader::autoload($transportName)) {
|
|
|
$transportName = ucfirst(strtolower($transportName));
|
|
|
|
|
|
- if(!Zend_Loader_Autoloader::autoload($transportName))
|
|
|
- {
|
|
|
+ if (!Zend_Loader_Autoloader::autoload($transportName)) {
|
|
|
$transportName = 'Zend_Mail_Transport_' . $transportName;
|
|
|
- if(!Zend_Loader_Autoloader::autoload($transportName)) {
|
|
|
+ if (!Zend_Loader_Autoloader::autoload($transportName)) {
|
|
|
throw new Zend_Application_Resource_Exception(
|
|
|
"Specified Mail Transport '{$transportName}'"
|
|
|
. 'could not be found'
|
|
|
@@ -128,10 +131,11 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
|
|
|
|
|
|
switch($transportName) {
|
|
|
case 'Zend_Mail_Transport_Smtp':
|
|
|
- if(!isset($options['host'])) {
|
|
|
+ if (!isset($options['host'])) {
|
|
|
throw new Zend_Application_Resource_Exception(
|
|
|
'A host is necessary for smtp transport,'
|
|
|
- .' but none was given');
|
|
|
+ . ' but none was given'
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
$transport = new $transportName($options['host'], $options);
|