email - PHP PEAR Container error -
allrighty, it's first time ask question here. problem awkward difficult bottom of. story goes this: have little system, sends alot of e-mail invitations(not spam). so, being sensible, don't use php function mail(), use pear classes mail, mail_queue, net_smtp, etc. problem is, error logs fill tons of errors this:
php notice: error in sending mail: mail queue error: cannot initialize container in /usr/lib/php/pear.php on line 873
and then, of course:
[18-feb-2011 17:38:44] php fatal error: allowed memory size of 33554432 bytes exhausted (tried allocate 3 bytes) in /usr/lib/php/pear.php on line 844
here's code inits mail queue(inside class called newsletter)
//i know passing dsn string kind of deprecated, //but it;'s way works on system $dsn ="mysql://$db_user:$db_pass@$db_host/$db_name"; $db_options = array(); $db_options['type'] = 'db'; $db_options['dsn'] = $dsn; $db_options['mail_table'] = table_queue; $this->host = '-- valid host here --';//data in these strings has been obscured $this->username = '-- valid username here --'; $this->password = '-- valid password here --'; //optionally, 'dns' string can provided instead of db parameters. //look @ db::connect() method or @ db or mdb docs details. //you use mdb container instead db //$server = isset($_server['server_name'])?$_server['server_name']:'localhost'; $mail_options = array( 'driver' => 'smtp', 'host' => $this->host, 'port' => 25, 'auth' => true, 'username' => $this->username, 'password' => $this->password, ); $this->mail_queue = new mail_queue($db_options, $mail_options);
some more code down line,
public function sendchunk($start, $count) { global $db; $ids = $db->get_results("select distinct id_user id ".table_queue); $ret = array(); foreach ($ids $id) $ret[] = $id->id; unset($ids); $this->mail_queue->sendmailsinqueue($count, $start, 1); return true; }
problem is, double checked every line of code wrote, , it's doing it's job. problem refuses send mails. in advance replies.
i switched mdb2 instead of db
$db_options['type'] = 'db';
to
$db_options['type'] = 'mdb2';
this helped in taking care of memory exhaust problem, still looking take care of initialize container in /usr/lib/php/pear.php
problem
ok found solution container errors: apply patch http://svn.php.net/viewvc/pear/packages/mail_queue/trunk/mail/queue.php?r1=303876&r2=309126
Comments
Post a Comment