 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
shadow man
Joined: 27 May 2009 Posts: 3
|
Posted: Wed May 27, 2009 4:09 pm Post subject: undefined method Mail_Queue_Error::getRecipient() |
|
|
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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1230
|
Posted: Thu May 28, 2009 3:25 pm Post subject: |
|
|
| 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 |
|
 |
shadow man
Joined: 27 May 2009 Posts: 3
|
Posted: Thu May 28, 2009 10:30 pm Post subject: |
|
|
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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1230
|
Posted: Fri May 29, 2009 12:19 pm Post subject: |
|
|
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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1230
|
Posted: Fri May 29, 2009 12:21 pm Post subject: |
|
|
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 |
|
 |
shadow man
Joined: 27 May 2009 Posts: 3
|
|
| Back to top |
|
 |
|
|
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
|
|