From: Alexander Ebert Date: Wed, 1 Jan 2014 12:51:19 +0000 (+0100) Subject: Providing sane values for SMTP on CLI X-Git-Tag: 2.0.1~8^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e2b370315d50fa7b3717c098e8721eae5cd57426;p=GitHub%2FWoltLab%2FWCF.git Providing sane values for SMTP on CLI --- diff --git a/wcfsetup/install/files/lib/system/mail/SMTPMailSender.class.php b/wcfsetup/install/files/lib/system/mail/SMTPMailSender.class.php index 1a1cd515d4..31bf103f86 100644 --- a/wcfsetup/install/files/lib/system/mail/SMTPMailSender.class.php +++ b/wcfsetup/install/files/lib/system/mail/SMTPMailSender.class.php @@ -63,8 +63,16 @@ class SMTPMailSender extends MailSender { throw new SystemException($this->formatError("can not connect to '".MAIL_SMTP_HOST.":".MAIL_SMTP_PORT."'")); } + $host = (isset($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : ''; + if (empty($host)) { + $host = gethostname(); + if ($host === false) { + $host = 'localhost'; + } + } + // send ehlo - $this->write('EHLO '.$_SERVER['HTTP_HOST']); + $this->write('EHLO '.$host); $this->getSMTPStatus(); if ($this->statusCode == 250) { // do authentication @@ -74,7 +82,7 @@ class SMTPMailSender extends MailSender { } else { // send helo - $this->write('HELO '.$_SERVER['HTTP_HOST']); + $this->write('HELO '.$host); $this->getSMTPStatus(); if ($this->statusCode != 250) { throw new SystemException($this->formatError("can not connect to '".MAIL_SMTP_HOST.":".MAIL_SMTP_PORT."'")); @@ -165,10 +173,18 @@ class SMTPMailSender extends MailSender { throw new SystemException($this->formatError("smtp error")); } + $serverName = (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : ''; + if (empty($serverName)) { + $serverName = gethostname(); + if ($serverName === false) { + $serverName = 'localhost'; + } + } + $header = "Date: ".gmdate('r').Mail::$lineEnding ."To: ".$mail->getToString().Mail::$lineEnding - ."Message-ID: <".md5(uniqid())."@".$_SERVER['SERVER_NAME'].">".Mail::$lineEnding + ."Message-ID: <".md5(uniqid())."@".$serverName.">".Mail::$lineEnding ."Subject: ".Mail::encodeMIMEHeader($mail->getSubject()).Mail::$lineEnding .$mail->getHeader();