PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
undefined method Mail_Queue_Error::getRecipient()

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail
View previous topic :: View next topic  
Author Message
shadow man



Joined: 27 May 2009
Posts: 3

PostPosted: Wed May 27, 2009 4:09 pm    Post subject: undefined method Mail_Queue_Error::getRecipient() Reply with quote

Hi,

I follow the how-to bug I have this error : Fatal error: Call to undefined method Mail_Queue_Error::getRecipient() in /usr/share/php/Mail/Queue.php on line 370

My code are :
Code:

$coeur->mail_perso_newsletter('Message de test', 'test de titre');
$coeur->mail_perso_newsletter_envoie();

And the class is :
Code:

public function mail_perso_newsletter($contenu_message, $nom_message, $ajout_entetes='', $entetes='', $expediteur='', $expediteur_pseudo='')
   {
      //Lance le chronomètre de la méthode
      $this->debut_chronometre(__CLASS__, __METHOD__);
      
      // Inclue la class que si elle est amenée à être utilisée
      require_once('Mail.php');
      require_once('Mail/mime.php');
      require_once('Mail/Queue.php');
      
      $mail_stockage = array(
         'type' => 'mdb2',
         'database' => 'tuks',
         'phptype' => 'mysql',
         'dsn' => 'mysql:'.NOM_UTILISATEUR.':'.MOT_DE_PASSE.'@localhost/tuks',
         'username' => NOM_UTILISATEUR,
         'password' => MOT_DE_PASSE,
         'mail_table' => 'mail_queue');
      $mail_options = array(
         'driver' => 'ssmtp',
         'host' => 'localhost',
         'port' => 25,
         'auth'     => false,
         'username' => '',
         'password' => '');
      // Options avncée à mettre
      $mail_queue =& new Mail_Queue($mail_stockage, $mail_options);
      
      // Gestion de l'expediteur
      if (!empty($expediteur))
      {
         $expediteur = (!empty($expediteur_pseudo)) ? $expediteur_pseudo.' <'.$expediteur.'>' : $expediteur ;
      }
      else
         $expediteur = $this->lang_coeur('L\'equipe de Tuks').' <'.MAIL_EQUIPE.'>';
         // Les accent sont interdit tant que le bug n'est pas corrigé
      
      $entetes = (!empty($entetes)) ? $entetes : array('From' => $expediteur,
            'Reply-to' => $this->lang_coeur('Support du site Tuks').' <'.MAIL_SUPPORT.'>',
            'Subject' => $nom_message,
            'To' => 'Admins <rem.73@free.fr>');
      $entetes = (!empty($ajout_entetes)) ? array_merge($entetes, $ajout_entetes) : $entetes;
      
      $mime = new Mail_mime("\r\n");
      
      $mime->setHTMLBody($contenu_message);
      
      $parametres = array('html_charset' => 'UTF-8',
            'text_charset' => 'UTF-8',
            'head_charset' => 'UTF-8',
            '7bit_wrap' => 70);
      $contenu_message = $mime->get($parametres);
      $entetes = $mime->headers($entetes);
      
      $mail_queue->put($expediteur, 'rem.73@free.fr', $entetes, $contenu_message, '10', FALSE, 1);
      $mail_queue->put($expediteur, 'rem-73@hotmail.fr', $entetes, $contenu_message, '10', FALSE, 2);
      
      //Arrète le chronomètre de la méthode
      $this->fin_chronometre(__CLASS__, __METHOD__);
   }
   
   public function mail_perso_newsletter_envoie()
   {
      require_once('Mail.php');
      require_once('Mail/mime.php');
      require_once('Mail/Queue.php');
      
      $mail_stockage = array(
         'type' => 'mdb2',
         'database' => 'tuks',
         'phptype' => 'mysql',
         'dsn' => 'mysql:'.NOM_UTILISATEUR.':'.MOT_DE_PASSE.'@localhost/tuks',
         'username' => NOM_UTILISATEUR,
         'password' => MOT_DE_PASSE,
         'mail_table' => 'mail_queue');
      $mail_options = array(
         'driver' => 'ssmtp',
         'host' => 'localhost',
         'port' => 25,
         'auth'     => false,
         'username' => '',
         'password' => '');
      
      $maximum_mails = 50;
      $mail_queue =& new Mail_Queue($mail_stockage, $mail_options);
      $mail_queue->sendMailsInQueue($maximum_mails, FALSE, 2);
         
      $mail =& Mail::factory('mail');
      echo($mail->send('rem.73@free.fr', $entetes, $contenu_message));
   }


The database are empty after use mail_perso_newsletter.


Thanks for your futur help.

Sorry if I speak not very well, I am french.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1230

PostPosted: Thu May 28, 2009 3:25 pm    Post subject: Reply with quote

There's likely an issue with initialization of the Mail_Queue object. You should check for errors there before calling sendMailsInQueue(). The methods hasErrors() and getErrors() should help you (only available in CVS version, not in the latest release of this package unfortunately).
Back to top
View user's profile Send private message
shadow man



Joined: 27 May 2009
Posts: 3

PostPosted: Thu May 28, 2009 10:30 pm    Post subject: Reply with quote

Thanks for your answer,

I use the CVS version of Mail_Queue and I change a bit my code for use the method hasErrors() and getErrors().

Code:
require_once(DOSSIER.'libs/pear_mail/Mail.php');
      require_once(DOSSIER.'libs/pear_mail/Mail/mime.php');
      require_once(DOSSIER.'libs/pear_mail/Mail/Queue.php');
      
      $mail_stockage = array(
         'type' => 'mdb2',
         'database' => 'tuks',
         'phptype' => 'mysql',
         'dsn' => 'mysql:'.NOM_UTILISATEUR.':'.MOT_DE_PASSE.'@localhost/tuks',
         'username' => NOM_UTILISATEUR,
         'password' => MOT_DE_PASSE,
         'mail_table' => 'mail_queue');
      $mail_options = array(
         'driver' => 'ssmtp',
         'host' => 'localhost',
         'port' => 25,
         'auth'     => false,
         'username' => '',
         'password' => '');
      
      $maximum_mails = 50;
      $mail_queue =& new Mail_Queue($mail_stockage, $mail_options);
      $mail_queue->factory($mail_stockage, $mail_options);
      if ($mail_queue->hasErrors())
      {
         echo $mail_queue->getErrors();
      }
      $mail_queue->sendMailsInQueue($maximum_mails, FALSE, 2);
         
      $mail =& Mail::factory('mail');
      echo($mail->send('rem.73@free.fr', $entetes, $contenu_message));


But I have just this error : Fatal error: Call to undefined method Mail_Queue_Error::getRecipient() in /home/remi/Tuks_0.0.3/libs/pear_mail/Mail/Queue.php on line 377

I have just the Mail_Queue CVS version, other package use the last ones version.

Thanks for your futur help.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1230

PostPosted: Fri May 29, 2009 12:19 pm    Post subject: Reply with quote

Well, as said in my first reply: There must be a problem with the initialization of the Mail_Queue object, maybe because of wrong credentials. And because of the failed initialization, several further methods calls won't work because the Mail object isn't available (i.e. is an instance of Mail_Queue_Error).

If the mentioned methods don't help, this sounds like a bug.

It might help to add the following lines for debugging purposes:
Code:

error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'PEAR.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);


=> The script will die once an PEAR_Error (Mail_Queue_Error is a subclass of it) and should output a (hopefully helpful) message.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1230

PostPosted: Fri May 29, 2009 12:21 pm    Post subject: Reply with quote

BTW, there might also be an issue with the include_path. If
Code:
require_once 'Mail.php';
doesn't work, the path is wrong and PEAR packages can't find the needed files.
Back to top
View user's profile Send private message
shadow man



Joined: 27 May 2009
Posts: 3

PostPosted: Fri May 29, 2009 6:57 pm    Post subject: Reply with quote

Hello,

I have debug with this post : http://209.85.229.132/search?q=cache:HXeWmTTFFPMJ:www.pear-forum.org/topic2075.html+MDB2+Error:+no+such+field&cd=4&hl=fr&ct=clnk&gl=fr&client=firefox-a
I just add the column sequence in the table mail_queue_seq (`sequence` int(10) default NULL).

And I use the driver 'sendmail'.

Thanks for all Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement