Skip to content
Permalink
Browse files

Ajusting smtpOption in EmailComponent. Fixes #779

  • Loading branch information...
jrbasso committed Jun 3, 2010
1 parent b480d80 commit 3c27c4c41e853be54ebf7434b6f94ac06f99b242
@@ -793,7 +793,8 @@ function _smtp() {
'protocol' => 'smtp',
'timeout' => 30
);
$this->__smtpConnection =& new CakeSocket(array_merge($defaults, $this->smtpOptions));
$this->smtpOptions = array_merge($defaults, $this->smtpOptions);
$this->__smtpConnection =& new CakeSocket($this->smtpOptions);
if (!$this->__smtpConnection->connect()) {
$this->smtpError = $this->__smtpConnection->lastError();
@@ -234,6 +234,30 @@ function __osFix($string) {
return str_replace(array("\r\n", "\r"), "\n", $string);
}
/**
* testSmtpConfig method
*
* @access public
* @return void
*/
function testSmtpConfig() {
$this->Controller->EmailTest->delivery = 'smtp';
$this->Controller->EmailTest->smtpOptions = array();
$this->Controller->EmailTest->send('anything');
$config = array(
'host' => 'localhost',
'port' => 25,
'protocol' => 'smtp',
'timeout' => 30
);
$this->assertEqual($config, $this->Controller->EmailTest->smtpOptions);
$this->Controller->EmailTest->smtpOptions = array('port' => 80);
$this->Controller->EmailTest->send('anything');
$config['port'] = 80;
$this->assertEqual($config, $this->Controller->EmailTest->smtpOptions);
}
/**
* testBadSmtpSend method
*
@@ -308,6 +332,7 @@ function testSmtpEhlo() {
$connection =& new CakeSocket(array('protocol'=>'smtp', 'host' => 'localhost', 'port' => 25));
$this->Controller->EmailTest->setConnectionSocket($connection);
$this->Controller->EmailTest->smtpOptions['timeout'] = 10;
$this->assertTrue($connection->connect());
$this->assertTrue($this->Controller->EmailTest->smtpSend(null, '220') !== false);
$this->skipIf($this->Controller->EmailTest->smtpSend('EHLO locahost', '250') === false, '%s do not support EHLO.');
@@ -600,6 +625,7 @@ function testTemplates() {
function testSmtpSendSocket() {
$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost');
$this->Controller->EmailTest->smtpOptions['timeout'] = 10;
$socket =& new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->Controller->EmailTest->smtpOptions));
$this->Controller->EmailTest->setConnectionSocket($socket);

0 comments on commit 3c27c4c

Please sign in to comment.
You can’t perform that action at this time.