View Full Version : PEAR Mail Queue

03-11-2009, 01:49 AM
Hello there,

I am attempting to use the PEAR Mail_Queue tool on my shared server. However, I am getting this error when it is called:

<b>Fatal error</b>: Call to a member function put() on a non-object in <b>/usr/local/lib/php/Mail/Queue.php</b> on line <b>428</b><br />

I do not know what the problem is, this is the function that calls it, and the associated arrays that it needs:

$mail_db_options["type"] = "db";
$mail_db_options["dsn"] = "mysql://user:pass@host/db";
$mail_db_options["mail_table"] = "mail_queue";

$mail_options["driver"] = "smtp";
$mail_options["host"] = "localhost";
$mail_options["port"] = 25;
$mail_options["localhost"] = "localhost"; //optional Mail_smtp parameter
$mail_options["auth"] = false;
$mail_options["username"] = "user";
$mail_options["password"] = "pass";

function mailqueue_add( $to, $from, $subject, $msg, $otherHeaders = array() ) {
$queue =& new Mail_Queue($mail_db_options, $mail_options);
$otherHeadrs['To'] = $to;
$otherHeaders['From'] = $from;
$otherHeaders['Subject'] = $subject;

$mime =& new Mail_mime();
$body = $mime->get();
$otherHeaders = $mime->headers($otherHeaders);
echo $body;
$queue->put($from, $to, $otherHeaders, $body);

Any help as to why this is happening is greatly appreciated!


mathew edison
03-11-2009, 10:48 AM
Is it just me or are you trying to pass along variables from an array without taking them out of the array first. If you know where the function is defined you can use the array as a whole to pass along your data. Otherwise the way you're defining $otherHeadrs['To'] won't work because the variable 'to' is caught within an array! :D:thumbsup:

03-11-2009, 04:20 PM
No the arrays are functioning properly, the problem was I needed to declare mail_db_options and mail_options as global so that they could be accessed when I instantiate the class. One of the most basic programming concepts... sometimes a break helps :) Thanks for your help!