Check return value of mail()
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 14 Jun 2016 21:22:25 +0000 (23:22 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 14 Jun 2016 21:22:25 +0000 (23:22 +0200)
wcfsetup/install/files/lib/system/email/transport/PhpEmailTransport.class.php

index 2f649ffd11f99b1fddc2fa9b673f148023145467..3f97c14313d46d162056ddd96d9ae97ba83fb1ff 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\system\email\transport;
+use wcf\system\email\transport\exception\TransientFailure;
 use wcf\system\email\Email;
 use wcf\system\email\Mailbox;
 use wcf\util\StringUtil;
@@ -41,10 +42,14 @@ class PhpEmailTransport implements EmailTransport {
                }, $headers));
                
                if (MAIL_USE_F_PARAM) {
-                       mail($envelopeTo->getAddress(), $email->getSubject(), StringUtil::unifyNewlines($email->getBodyString()), $headers, '-f'.$email->getSender()->getAddress());
+                       $return = mail($envelopeTo->getAddress(), $email->getSubject(), StringUtil::unifyNewlines($email->getBodyString()), $headers, '-f'.$email->getSender()->getAddress());
                }
                else {
-                       mail($envelopeTo->getAddress(), $email->getSubject(), StringUtil::unifyNewlines($email->getBodyString()), $headers);
+                       $return = mail($envelopeTo->getAddress(), $email->getSubject(), StringUtil::unifyNewlines($email->getBodyString()), $headers);
+               }
+               
+               if (!$return) {
+                       throw new TransientFailure("mail() returned false");
                }
        }
 }