File: Queue.php
Source Location: /Mail_Queue-1.1.2/Queue.php
Classes:
Mail_Queue
Mail_Queue - base class for mail queue managment.
Mail_Queue_Error
Mail_Queue_Error implements a class for reporting error messages.
Page Details:
Class for handle mail queue managment.
Wrapper for Pear::Mail and Pear::DB. Could load, save and send saved mails in background and also backup some mails. Mail queue class put mails in a temporary container waiting to be fed to the MTA (Mail Transport Agent) and send them later (eg. every few minutes) by crontab or in other way. ------------------------------------------------------------------------- A basic usage example: ------------------------------------------------------------------------- $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' => 'your_smtp_server.com', 'port' => 25, 'auth' => false, 'username' => '', 'password' => '' ); $mail_queue =& new Mail_Queue($container_options, $mail_options); ***************************************************************** // Here the code differentiates wrt you want to add an email to the queue // or you want to send the emails that already are in the queue. ***************************************************************** // TO ADD AN EMAIL TO THE QUEUE ***************************************************************** $from = 'user@server.com'; $from_name = 'admin'; $recipient = 'recipient@other_server.com'; $recipient_name = 'recipient'; $message = 'Test message'; $from_params = empty($from_name) ? '"'.$from_name.'" <'.$from.'>' : '<'.$from.'>'; $recipient_params = empty($recipient_name) ? '"'.$recipient_name.'" <'.$recipient.'>' : '<'.$recipient.'>'; $hdrs = array( 'From' => $from_params, 'To' => $recipient_params, 'Subject' => "test message body" ); $mime =& new Mail_mime(); $mime->setTXTBody($message); $body = $mime->get(); $hdrs = $mime->headers($hdrs); // Put message to queue $mail_queue->put( $from, $recipient, $hdrs, $body ); //Also you could put this msg in more advanced mode [look at Mail_Queue docs for details] $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 ); ***************************************************************** // TO SEND EMAILS IN THE QUEUE ***************************************************************** // How many mails could we send each time $max_ammount_mails = 50; $mail_queue =& new Mail_Queue($container_options, $mail_options); $mail_queue->sendMailsInQueue($max_ammount_mails); ***************************************************************** // for more examples look to docs directory // end usage example -------------------------------------------------------------------------
Includes:
require_once('Mail.php') [line 145]
require_once('PEAR.php') [line 144]
require_once('Mail/mime.php') [line 146]
MAILQUEUE_ALL [line 116]
MAILQUEUE_ERROR [line 134]
MAILQUEUE_ERROR_CANNOT_CONNECT [line 139]
MAILQUEUE_ERROR_CANNOT_INITIALIZE [line 137]
MAILQUEUE_ERROR_CANNOT_SEND_MAIL [line 142]
MAILQUEUE_ERROR_NO_CONTAINER [line 136]
MAILQUEUE_ERROR_NO_DRIVER [line 135]
MAILQUEUE_ERROR_NO_OPTIONS [line 138]
MAILQUEUE_ERROR_QUERY_FAILED [line 140]
MAILQUEUE_ERROR_UNEXPECTED [line 141]
MAILQUEUE_START [line 110]
MAILQUEUE_SYSTEM [line 122]
MAILQUEUE_TRY [line 129]
MAILQUEUE_UNKNOWN [line 123]
Documentation generated on Mon, 11 Mar 2019 13:54:01 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|