Email Marketing
Tue, 18 July, 2006 – 7:45 pm
No not spamming! I've been working on and searching for a good script to allow a client to send out manual alerts to customers for various products or new offers. All legit before you wonder!
I had 99% of the script finished however with 8000+ emails in the database there was no way the simple mail() function in PHP would work. So after a few searches around forums I came across Swift Mailer, a bolt on PHP class similar to PHP Mailer however it requires less input and the main and most important ingredient is that it can batch email send. You simply choose how many emails to send and how often to send them and it will just pause itself, no need for messing with CRON jobs etc.
I've not worked out how to send out a personalised message to each person, but I'm sure it's in there if I looked further! Anyhow, a handy script for anyone who needs to batch their email sending.


Ive used this before, its really useful
By Matt on Tue, 18 July, 2006
I worked around the same problem – personalise a bulk email – in a different way, the opposite way in fact.
Using just my normal PHP mail code with an email personalised with names, login links etc (drawn from a database or from an array) and sent out by using a simple loop and javascript refresh passing the user_id to get the next email to send every couple of seconds. It just opens in a browser and sends until complete or until the browser is closed.
Easy peasy and not very intense on the server either.
By Liam on Thu, 20 July, 2006
Hey Liam,
Sounds like a good solution, not something that crossed my mind to be honest. I think I forget the usefulness of javascript at times despite using it so much pre-PHP times!
Thanks for the additional option
By Sarah on Thu, 20 July, 2006
Hi Sarah!
FYI, If you download version 2.0 released yesterday you'll find a templating plugin which is for doing simple replacements in the mail body on a batch send. I've not quite sorted it to replace strings in the headers yet but this should become available in future versions. It does what you want in terms of customizing the email for each recipient.
No documentation for the plugin given that it was just released yesterday but this is the essence of it… note the name changes in version 2 – I don't particularly like it but it's PEAR standards and people have been asking for it
<?php
$addresses = array(' "Chris Corbyn1" ', ' "Chris Corbyn2" ', ' "Chris Corbyn3" ');
.
$tpl = array (
array ('foo' => 'First email'),
array ('foo' => 'second email'),
array ('foo' => 'third email')
);
.
$mailer->loadPlugin(new Swift_Plugin_Template($tpl));
.
$mailer->send(
$addresses,
'"Your name" ',
'Some Subject',
"It's only me! and this is my {foo}!!!"
);
.
$mailer->close();
?>
Regards,
Chris
By Chris on Mon, 31 July, 2006
Hmm…. the blog messed my code up
Email me if you want some advice
By Chris on Mon, 31 July, 2006
Hey Chris, thanks for stopping by to let me know about version 2.0. I'll definitely grab it as I'm possibly about to use it on another site too!
I took a guess at the missing code above and hopefully fixed it. I do get the jist however and once I try it I'll post up my definite working code for anyone else who's interested
By Sarah on Mon, 31 July, 2006