]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Email.php
Merge pull request #12591 from MrPetovan/task/2023-licence
[friendica.git] / src / Object / Email.php
index 43cf8eb2d0c3b9a82e26bdea63ce7dd55d2aeb08..f6a72985231af6b58c42518f5664a5069fc1edc4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -110,12 +110,12 @@ class Email implements IEmail
        /**
         * {@inheritDoc}
         */
-       public function getMessage(bool $plain = false)
+       public function getMessage(bool $plain = false): string
        {
                if ($plain) {
                        return $this->msgText;
                } else {
-                       return $this->msgHtml;
+                       return $this->msgHtml ?? '';
                }
        }
 
@@ -135,14 +135,15 @@ class Email implements IEmail
                $headerString = '';
 
                foreach ($this->additionalMailHeader as $name => $values) {
-                       if (is_array($values)) {
-                               foreach ($values as $value) {
-                                       $headerString .= "$name: $value\n";
-                               }
-                       } else {
-                               $headerString .= "$name: $values\n";
+                       if (!is_array($values)) {
+                               $values = [$values];
+                       }
+
+                       foreach ($values as $value) {
+                               $headerString .= "$name: $value\r\n";
                        }
                }
+
                return $headerString;
        }
 
@@ -199,6 +200,7 @@ class Email implements IEmail
        /**
         * @inheritDoc
         */
+       #[\ReturnTypeWillChange]
        public function jsonSerialize()
        {
                return $this->toArray();