diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:29:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:29:16 +0000 |
commit | 8a985929ed84cdb458a13c66b25f84e41133b24f (patch) | |
tree | 102a3d6e3cb731c6d23263095d0098f99572626d /library/Reporting/Mail.php | |
parent | Adding upstream version 0.10.0. (diff) | |
download | icingaweb2-module-reporting-8a985929ed84cdb458a13c66b25f84e41133b24f.tar.xz icingaweb2-module-reporting-8a985929ed84cdb458a13c66b25f84e41133b24f.zip |
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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) { |