Permalink
Browse files

config() will apply configs from email.php if string is passed

  • Loading branch information...
1 parent 54e1de9 commit 803cd287c26d6cb411b8f4d330423801c9ef42c3 @ceeram ceeram committed Aug 17, 2011
Showing with 14 additions and 15 deletions.
  1. +14 −15 lib/Cake/Network/Email/CakeEmail.php
@@ -892,14 +892,13 @@ public function config($config = null) {
if (is_array($config)) {
$this->_config = $config;
+ if ($this->_transportClass) {
+ $this->_transportClass->config($this->_config);
+ }
} else {
$this->_config = (string)$config;
+ self::_applyConfig($this, $this->_config);
}
-
- if ($this->_transportClass) {
- $this->_transportClass->config($this->_config);
- }
-
return $this;
}
@@ -991,16 +990,6 @@ public static function deliver($to = null, $subject = null, $message = null, $tr
$class = __CLASS__;
$instance = new $class();
- if (is_string($transportConfig)) {
- if (!config('email')) {
- throw new SocketException(__d('cake', '%s not found.', APP . 'Config' . DS . 'email.php'));
- }
- $configs = new EmailConfig();
- if (!isset($configs->{$transportConfig})) {
- throw new SocketException(__d('cake', 'Unknown email configuration "%s".', $transportConfig));
- }
- $transportConfig = $configs->{$transportConfig};
- }
self::_applyConfig($instance, $transportConfig);
if ($to !== null) {
@@ -1031,6 +1020,16 @@ public static function deliver($to = null, $subject = null, $message = null, $tr
* @return void
*/
protected static function _applyConfig(CakeEmail $obj, $config) {
+ if (is_string($config)) {
+ if (!config('email')) {
+ throw new SocketException(__d('cake', '%s not found.', APP . 'Config' . DS . 'email.php'));
+ }
+ $configs = new EmailConfig();
+ if (!isset($configs->{$config})) {
+ throw new SocketException(__d('cake', 'Unknown email configuration "%s".', $config));
+ }
+ $config = $configs->{$config};
+ }
$simpleMethods = array(
'from', 'sender', 'to', 'replyTo', 'readReceipt', 'returnPath', 'cc', 'bcc',
'messageId', 'subject', 'viewRender', 'viewVars', 'attachments',

0 comments on commit 803cd28

Please sign in to comment.