Throw proper exception on empty email body
authorTim Düsterhus <duesterhus@woltlab.com>
Sat, 11 Jun 2016 20:07:34 +0000 (22:07 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sat, 11 Jun 2016 20:07:34 +0000 (22:07 +0200)
wcfsetup/install/files/lib/system/email/Email.class.php

index 15af4756aadb58756494612b4c4c68c4c4cfd107..4764f3a0cd8a4a6b2c756c8a9475b57f33ae05c8 100644 (file)
@@ -446,6 +446,10 @@ class Email {
         * @return      string
         */
        public function getBodyString() {
+               if ($this->body === null) {
+                       throw new \LogicException('Cannot generate message body, you must specify a body');
+               }
+               
                switch ($this->body->getContentTransferEncoding()) {
                        case 'quoted-printable':
                                return quoted_printable_encode($this->body->getContent());
@@ -471,6 +475,9 @@ class Email {
                // ensure every header is filled in
                $this->getHeaders();
                
+               // ensure the body is filled in
+               $this->getBodyString();
+               
                foreach ($this->recipients as $recipient) {
                        $mail = clone $this;