From 1a3abe0ea02c176fff76784781a3977c3ae9e464 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 11 Jun 2016 22:07:34 +0200 Subject: [PATCH] Throw proper exception on empty email body --- wcfsetup/install/files/lib/system/email/Email.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wcfsetup/install/files/lib/system/email/Email.class.php b/wcfsetup/install/files/lib/system/email/Email.class.php index 15af4756aa..4764f3a0cd 100644 --- a/wcfsetup/install/files/lib/system/email/Email.class.php +++ b/wcfsetup/install/files/lib/system/email/Email.class.php @@ -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; -- 2.20.1