Skip to content

Commit

Permalink
Improve the way that hostname is obtained, should be safer in CLI scr…
Browse files Browse the repository at this point in the history
…ipts, fixes PHPMailer#159
  • Loading branch information
Synchro committed Dec 30, 2013
1 parent 15f53e6 commit 6767b0f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions class.phpmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2717,14 +2717,14 @@ public static function rfcDate()
*/
protected function serverHostname()
{
$result = 'localhost.localdomain';
if (!empty($this->Hostname)) {
$result = $this->Hostname;
} elseif (isset($_SERVER['SERVER_NAME'])) {
} elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
$result = $_SERVER['SERVER_NAME'];
} else {
$result = 'localhost.localdomain';
} elseif (gethostname() !== false) {
$result = gethostname();
}

return $result;
}

Expand Down

0 comments on commit 6767b0f

Please sign in to comment.