Browse Source

Clarify EmailLib usage

euromark 11 years ago
parent
commit
782bce9ae9
2 changed files with 7 additions and 1 deletions
  1. 6 0
      Lib/EmailLib.php
  2. 1 1
      Test/Case/Console/Command/EncodingShellTest.php

+ 6 - 0
Lib/EmailLib.php

@@ -450,6 +450,9 @@ class EmailLib extends CakeEmail {
 		// Security measure to not sent to the actual addressee in debug mode
 		if (Configure::read('debug')) {
 			$adminEmail = Configure::read('Config.adminEmail');
+			if (!$adminEmail) {
+				$adminEmail = Configure::read('Config.systemEmail');
+			}
 			foreach ($this->_to as $k => $v) {
 				if ($k === $adminEmail) {
 					continue;
@@ -613,6 +616,9 @@ class EmailLib extends CakeEmail {
 			$fromEmail = Configure::read('Config.adminEmail');
 			$fromName = Configure::read('Config.adminName');
 		}
+		if (!$fromEmail) {
+			throw new RuntimeException('You need to either define systemEmail or adminEmail in Config.');
+		}
 		$this->from($fromEmail, $fromName);
 
 		if ($xMailer = Configure::read('Config.xMailer')) {

+ 1 - 1
Test/Case/Console/Command/EncodingShellTest.php

@@ -15,7 +15,7 @@ class EncodingShellTest extends MyCakeTestCase {
 		$error = $this->getMock('ConsoleOutput', array(), array(), '', false);
 		$input = $this->getMock('ConsoleInput', array(), array(), '', false);
 
-		$this->EncodingShell = new EncodingShell($output, $error, $input);
+		$this->EncodingShell = new TestEncodingShell($output, $error, $input);
 		$this->EncodingShell->initialize();
 		$this->EncodingShell->startup();
 	}