diff options
Diffstat (limited to 'library/Reporting/Mail.php')
-rw-r--r-- | library/Reporting/Mail.php | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/library/Reporting/Mail.php b/library/Reporting/Mail.php index 7581f45..810b166 100644 --- a/library/Reporting/Mail.php +++ b/library/Reporting/Mail.php @@ -1,4 +1,5 @@ <?php + // Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2 namespace Icinga\Module\Reporting; @@ -11,15 +12,15 @@ use Zend_Mime_Part; class Mail { /** @var string */ - const DEFAULT_SUBJECT = 'Icinga Reporting'; + public const DEFAULT_SUBJECT = 'Icinga Reporting'; - /** @var string */ + /** @var ?string */ protected $from; /** @var string */ protected $subject = self::DEFAULT_SUBJECT; - /** @var Zend_Mail_Transport_Sendmail */ + /** @var ?Zend_Mail_Transport_Sendmail */ protected $transport; /** @var array */ @@ -43,7 +44,7 @@ class Mail } foreach (['HTTP_HOST', 'SERVER_NAME', 'HOSTNAME'] as $key) { - if (isset($_SEVER[$key])) { + if (isset($_SERVER[$key])) { $this->from = 'icinga-reporting@' . $_SERVER[$key]; return $this->from; @@ -58,7 +59,7 @@ class Mail /** * Set the from part * - * @param string $from + * @param string $from * * @return $this */ @@ -82,7 +83,7 @@ class Mail /** * Set the subject * - * @param string $subject + * @param string $subject * * @return $this */ @@ -161,14 +162,14 @@ class Mail { $mail = new Zend_Mail('UTF-8'); - $mail->setFrom($this->getFrom()); + $mail->setFrom($this->getFrom(), ''); $mail->addTo($recipient); $mail->setSubject($this->getSubject()); - if (strlen($body) !== strlen(strip_tags($body))) { + if ($body && (strlen($body) !== strlen(strip_tags($body)))) { $mail->setBodyHtml($body); } else { - $mail->setBodyText($body); + $mail->setBodyText($body ?? ''); } foreach ($this->attachments as $attachment) { |