summaryrefslogtreecommitdiffstats
path: root/library/Reporting/Mail.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:29:16 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:29:16 +0000
commit8a985929ed84cdb458a13c66b25f84e41133b24f (patch)
tree102a3d6e3cb731c6d23263095d0098f99572626d /library/Reporting/Mail.php
parentAdding upstream version 0.10.0. (diff)
downloadicingaweb2-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.php19
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) {