constructor Mail_Queue::Mail_Queue

constructor Mail_Queue::Mail_Queue() – Mail_Queue constructor


require_once 'Mail/Queue.php';

mixed constructor Mail_Queue::Mail_Queue ( array $container_options , array $mail_options )


Creates a new mail queue object to store mails in, fetch mails from and send mails with.


array $container_options

Array of container (mail storage) options. See tutorial for details.

array $mail_options

Array of mailer options. See tutorial for details.


require_once 'Mail/Queue.php';

$container_options = array(
'type'        => 'db',
'database'    => 'dbname',
'phptype'     => 'mysql',
'username'    => 'root',
'password'    => '',
'mail_table'  => 'mail_queue',
//optionally, a 'dns' string can be provided instead of db parameters.
//look at DB::connect() method or at DB or MDB docs for details.
//you could also use mdb container instead db
$mail_options = array(
'driver'   => 'smtp',
'host'     => '',
'port'     => 25,
'auth'     => false,
'username' => '',
'password' => '',

$mail_queue =& new Mail_Queue($container_options$mail_options);

* *****************************************************************
* *****************************************************************
$from             '';
$from_name        'admin';
$recipient        '';
$recipient_name   'recipient';
$message          'Test message';
$from_params      = empty($from_name) ? '<'.$from.'>' '"'.$from_name.'" <'.$from.'>';
$recipient_params = empty($recipient_name) ? '<'.$recipient.'>' '"'.$recipient_name.'" <'.$recipient.'>';
$hdrs = array(
'From'    => $from_params,
'To'      => $recipient_params,
'Subject' => 'test message body',
$mime =& new Mail_mime();
$body $mime->get();
$hdrs $mime->headers($hdrs);

// Put message to queue

// Also you could put this msg in more advanced mode
$seconds_to_send 3600;
$delete_after_send false;
$id_user 7;
$mail_queue->put$from$recipient$hdrs$body$seconds_to_send$delete_after_send$id_user );


// How many mails could we send each time
$max_ammount_mails 50;
$mail_queue =& new Mail_Queue($container_options$mail_options);


Return value

returnsTrue on success else pear error class.


throws no exceptions thrown


This function can not be called statically.

A tutorial for Mail_Queue (Previous) Delete a mail from queue. (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

Note by:
If you having problems with the connection to the database, check the documentation at
Note by:
I'm trying to use a remote database with this. In my code, I connect with a connection string that looks like this:

$link = mysql_connect("","mydatabase_user","mydatabase_password") or die('Could not connect: ' . mysql_error());
mysql_select_db('mydatabase_name') or die('Could not select database');

I can't figure out how to set this up in the config file.

$db_options['type'] = 'db';
$db_options['database'] = 'mydatabase_name';
$db_options['phptype'] = 'mysql';
$db_options['username'] = 'mydatabase_user';
$db_options['password'] = 'mydatabase_password';
$db_options['mail_table'] = 'mail_queue';

Where do I put the IP of the server with the database?