Batch send with the same address twice

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
rabw
Forum Newbie
Posts: 18
Joined: Tue May 29, 2007 5:57 pm

Batch send with the same address twice

Post by rabw »

Hi everyone, I've had a search and on google but cannot find anything about this so...

I'm actually pleased with myself so far, I've never really done php before and I have made the batchsend work from input from an XML/XSL file via a post which is generated by a 3rd party system with no emailing capabilities.

But now I'm stuck.

My problem is that if the same recipient comes up for an email more than once, the 1st email to them works, but any other emails do not send. I'm not sure if it's something I'm doing wrong or if it is a limitation with the batchsend.

Also (maybe should make a seperate post), to make the php batchsend page pick up the email addresses and other variables I have to write:

Code: Select all

if (!empty($_POST["rcpt1"])){$rcpt1 = $_POST["rcpt1"];}
if (!empty($_POST["rcpt2"])){$rcpt2 = $_POST["rcpt2"];}
if (!empty($_POST["rcpt3"])){$rcpt3 = $_POST["rcpt3"];}
and so on... It doesnt stop it working if the input is empty obviously, but it seems inelegant... surely there is a neater way to do this, something like:

Code: Select all

if (!empty($_POST["rcpt{1-500}"])){$rcpt{1-500} = $_POST["rcpt{1-500}"];}
Thanks in advance for any light you can shed on this. I'm happy to share my code if anyone feels it would be of use to them, but I'm guessing this would be a simple task for most people here!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

batchSend() is designed (or more specifically Swift_RecipientList is designed) to ignore duplicates. More people would rather avoid duplicates than the number of people who actually do want duplicates. I'd just use a loop with send() instead, or manually send the duplicates if you know what they are.

I'll have a quick look at how easy it would be to get the list to provide duplicates but right now it's a no-go I'm afraid.
rabw
Forum Newbie
Posts: 18
Joined: Tue May 29, 2007 5:57 pm

Post by rabw »

I will have a look at send(), but I need to be able to hide other addresses obviously. There are duplicates because these emails are alerts for members of the site with a ref no. in (passed with their email address in the post) of what they may be interested in. Because of these variables/fields in the emails they arent 100% duplicates, just the same template.

One member could have more than one 'alert' come up at any one time with diff ref no.'s so this is why there is the possibility of more than one message to the same person when the php script is run to send the emails.

There's potentially 2000-5000+ emails a day so would rather not send by hand :lol:
Post Reply