OxyScripts.com
Menu spacer Home Tutorials Articles Code Forums irc.freenode.net #oxyscripts
Main (PHP)
Home Forums PHP News PHP Tutorials Articles PHP Code Snippets Contact Us Sysadmin Resources Books Template Shop
3rd Party Streams
SlashDot PHPDeveloper.org PHP.Net
Resources
PHP Manual MySQL Manual Smarty Manual PEAR Manual PHP-GTK Manual Symfony Manual
Code Snippets
Authentication Database Graphics HTTP Miscellaneous Time/Date
Affiliates
Scripts TutorialMan TutorialGuide CodingForums.com PHP Scripts Cheap Web Hosting Affordable Web Hosting Dreamweaver Templates

Search This Site :     PHP Function Reference :
 
constructor Mail_Queue::Mail_Queue

constructor Mail_Queue::Mail_Queue()

constructor Mail_Queue::Mail_Queue() -- Mail_Queue constructor

Description

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

Parameter

array $container_options

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

array $mail_options

Array of mailer options. See tutorial for details.

Example 36-1.

<?php

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'     => 'your_smtp_server.com',
  'port'     => 25,
  'auth'     => false,
  'username' => '',
  'password' => ''
);

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

* *****************************************************************
* // 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
$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);

?>

Return value

returnsTrue on success else pear error class.

Throws

throws no exceptions thrown

Note

This function can not be called statically.

 
   Print this page

Top Sponsor
Symantec\'s Norton SystemWorks 2006
Sponsors
CA
Sponsors
AdWords Dominator 125*125
Advertisting

Affiliates
VertexTemplates PHPFreaks CodeWalkers StarGeek DevScripts CGI & PHP Scripts PHP CMS

Shopping Rebates   Sell It 4 You   Flash Page Counters   Get Insured
GPS Tracking Service   Charity Donate Info   Web Site Hosting   VOIP Service

Privacy Policy | Links | Site Map | Advertising

All content on OxyScripts.com is (©)2002-2007

 
Powered by Adrastea - Version 1.0.0. Copyright © Rune Solutions, 2004-2005