i would like to send many emails (like 50.000)
i get the emails and user from a mysql db and i can not store this in arrays (max mb size is 8MB for php)
i can increase the php max value but i think this is not a good idea ?
how can i use the template and the AntiFlood Plugins ?
i think i can only use the standard send option
every email a ne send()
any ideas
sample code from me
Code: Select all
require('Swift-2.1.17-php4/Swift/Connection/SMTP.php');
require('Swift-2.1.17-php4/Swift.php');
require('Swift-2.1.17-php4/Swift/Plugin/AntiFlood.php');
require('Swift-2.1.17-php4/Swift/Plugin/Template.php');
require('Swift-2.1.17-php4/Swift/Plugin/Swift_Plugin_CustomiseEachEmail.php');
$sql="SELECT ";
$dbh = new db_handler();
$dbh->dbQueryOnce($sql);
while ($row = $dbh->dbGetRow())
{
echo $row['nickname'];
if($row['nickname'])
$nickname = trim($row['nickname']);
else
$nickname = $row['email'];
//$email[] = array($nickname, $row['email']);
//$user[] = array('id'=>$row['user_id'], 'name'=>$nickname);
}
//print_r($user);Code: Select all
$mailer = new Swift(new Swift_Connection_SMTP('localhost'));
$mailer->loadPlugin(new Swift_Plugin_AntiFlood(100, 30));
$recipients = array(
'you@examplel.com',
'me@example.com',
);
$tpl = array (
array ('id' => '1' , 'foo' => 'First email' , 'name' => 'Jhon'),
array ('id' => '2' , 'foo' => 'second email', 'name' => 'whwi')
);
$mailer->loadPlugin(new Swift_Plugin_CustomiseEachEmail($tpl));
//$mailer->loadPlugin(new Swift_Plugin_Template($tpl));
//Add as many parts as you need here
$mailer->addPart('Some {foo} plain {name} text part');
$mailer->addPart(' {id} Some HTML <strong>part with bold</strong> text', 'text/html');
//Make the script run until it's finished in the background
set_time_limit(0); ignore_user_abort();
echo "Close the browser window now...";
flush(); ob_flush();
//Leaving the body out of send() makes the mailer send a multipart message
echo $mailer->send(
$recipients,
'"you" <webmaster@you.com>',
'Some Subject'
);
print_r($mailer->transactions);
print_r($mailer->getFailedRecipients());
$mailer->close();whwi