apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

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 -------------------------------------------------------------------------

  • Author: Radek Maciaszek <chief@php.net>
  • Version: $Revision: 1.14 $ $Id: Queue.php,v 1.14 2004/07/18 14:59:15 quipo Exp $

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_ALL = -1
You can specify how many mails will be loaded to queue else object use this constant for load all mails from db.

[ Top ]



MAILQUEUE_ERROR [line 134]

MAILQUEUE_ERROR = -1
MAILQUEUE_ERROR constants

[ Top ]



MAILQUEUE_ERROR_CANNOT_CONNECT [line 139]

MAILQUEUE_ERROR_CANNOT_CONNECT = -6

[ Top ]



MAILQUEUE_ERROR_CANNOT_INITIALIZE [line 137]

MAILQUEUE_ERROR_CANNOT_INITIALIZE = -4

[ Top ]



MAILQUEUE_ERROR_CANNOT_SEND_MAIL [line 142]

MAILQUEUE_ERROR_CANNOT_SEND_MAIL = -9

[ Top ]



MAILQUEUE_ERROR_NO_CONTAINER [line 136]

MAILQUEUE_ERROR_NO_CONTAINER = -3

[ Top ]



MAILQUEUE_ERROR_NO_DRIVER [line 135]

MAILQUEUE_ERROR_NO_DRIVER = -2

[ Top ]



MAILQUEUE_ERROR_NO_OPTIONS [line 138]

MAILQUEUE_ERROR_NO_OPTIONS = -5

[ Top ]



MAILQUEUE_ERROR_QUERY_FAILED [line 140]

MAILQUEUE_ERROR_QUERY_FAILED = -7

[ Top ]



MAILQUEUE_ERROR_UNEXPECTED [line 141]

MAILQUEUE_ERROR_UNEXPECTED = -8

[ Top ]



MAILQUEUE_START [line 110]

MAILQUEUE_START = 0
This is special constant define start offset for limit sql queries to get mails.

[ Top ]



MAILQUEUE_SYSTEM [line 122]

MAILQUEUE_SYSTEM = -1
When you put new mail to queue you could specify user id who send e-mail.

Else you could use system id: MAILQUEUE_SYSTEM or user unknown id: MAILQUEUE_UNKNOWN


[ Top ]



MAILQUEUE_TRY [line 129]

MAILQUEUE_TRY = 25
This constant tells Mail_Queue how many times should try to send mails again if was any errors before.

[ Top ]



MAILQUEUE_UNKNOWN [line 123]

MAILQUEUE_UNKNOWN = -2

[ Top ]



Documentation generated on Mon, 11 Mar 2019 13:54:01 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.