Skip to content

Commit 4dc656f

Browse files
committed
Updating EmailComponent smtp HELO handling to account for non-existence of HTTP_HOST environment variable when PHP SAPI is CLI. Fixes #41.
1 parent 2484179 commit 4dc656f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cake/libs/controller/components/email.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,14 @@ function __smtp() {
680680
return false;
681681
}
682682

683+
$httpHost = env('HTTP_HOST');
684+
683685
if (isset($this->smtpOptions['client'])) {
684686
$host = $this->smtpOptions['client'];
687+
} elseif (!empty($httpHost)) {
688+
$host = $httpHost;
685689
} else {
686-
$host = env('HTTP_HOST');
690+
$host = 'localhost';
687691
}
688692

689693
if (!$this->__smtpSend("HELO {$host}", '250')) {

cake/tests/cases/libs/controller/components/email.test.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,9 @@ function testSmtpSendSocket() {
478478
$response = $this->Controller->EmailTest->smtpSend('HELO', '250');
479479
$this->assertPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError);
480480

481-
$this->Controller->EmailTest->smtpError = null;
481+
$this->Controller->EmailTest->reset();
482482
$response = $this->Controller->EmailTest->smtpSend('HELO somehostname', '250');
483483
$this->assertNoPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError);
484-
485484
}
486485
/**
487486
* testSendDebug method

0 commit comments

Comments
 (0)