cvs: pear /Mail_Queue Queue.php

[email protected] ("Till Klampaeckel") Tue, 06 May 2008 20:47:23 -0000
Newsgroups php.pear.cvs
Message-ID <cvstill1210106843@cvsserver>
till		Tue May  6 20:47:23 2008 UTC

  Modified files:              
    /pear/Mail_Queue	Queue.php 
  Log:
  * added another check in sendMail() (to check if Mail_Queue::$send_mail contains a valid object of Mail)
  
  
  
http://cvs.php.net/viewvc.cgi/pear/Mail_Queue/Queue.php?r1=1.25&r2=1.26&diff_format=u
Index: pear/Mail_Queue/Queue.php
diff -u pear/Mail_Queue/Queue.php:1.25 pear/Mail_Queue/Queue.php:1.26
--- pear/Mail_Queue/Queue.php:1.25	Sun May  4 08:26:45 2008
+++ pear/Mail_Queue/Queue.php	Tue May  6 20:47:22 2008
@@ -17,7 +17,7 @@
 // |          Lorenzo Alberton <[email protected]>                      |
 // +----------------------------------------------------------------------+
 //
-// $Id: Queue.php,v 1.25 2008/05/04 08:26:45 quipo Exp $
+// $Id: Queue.php,v 1.26 2008/05/06 20:47:22 till Exp $
 
 /**
 * Class for handle mail queue managment.
@@ -98,8 +98,8 @@
 * // end usage example
 * -------------------------------------------------------------------------
 *
-* @version $Revision: 1.25 $
-* $Id: Queue.php,v 1.25 2008/05/04 08:26:45 quipo Exp $
+* @version $Revision: 1.26 $
+* $Id: Queue.php,v 1.26 2008/05/06 20:47:22 till Exp $
 * @author Radek Maciaszek <[email protected]>
 */
 
@@ -140,6 +140,7 @@
 define('MAILQUEUE_ERROR_QUERY_FAILED',      -7);
 define('MAILQUEUE_ERROR_UNEXPECTED',        -8);
 define('MAILQUEUE_ERROR_CANNOT_SEND_MAIL',  -9);
+define('MAILQUEUE_ERROR_NO_RECIPIENT',     -10);
 
 require_once 'PEAR.php';
 require_once 'Mail.php';
@@ -150,7 +151,7 @@
  * Mail_Queue - base class for mail queue managment.
  *
  * @author   Radek Maciaszek <[email protected]>
- * @version  $Id: Queue.php,v 1.25 2008/05/04 08:26:45 quipo Exp $
+ * @version  $Id: Queue.php,v 1.26 2008/05/06 20:47:22 till Exp $
  * @package  Mail_Queue
  * @access   public
  */
@@ -367,11 +368,20 @@
     function sendMail($mail, $set_as_sent=true)
     {
         $recipient = $mail->getRecipient();
+        if (empty($recipient)) {
+            return new Mail_Queue_Error('Recipient cannot be empty.',
+                MAILQUEUE_ERROR_NO_RECIPIENT);
+        }
+
         $hdrs = $mail->getHeaders();
         $body = $mail->getBody();
+
         if (empty($this->send_mail)) {
             $this->factorySendMail();
         }
+        if (PEAR::isError($this->send_mail)) {
+            return $this->send_mail;
+        }
         $sent = $this->send_mail->send($recipient, $hdrs, $body);
         if (!PEAR::isError($sent) && $sent && $set_as_sent) {
             $this->container->setAsSent($mail);
@@ -551,4 +561,4 @@
 
     // }}}
 }
-?>
\ No newline at end of file
+?>