PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Mar 30, 2020 7:56 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Mar 13, 2007 1:31 pm 
Offline
Forum Commoner

Joined: Sun May 15, 2005 11:38 am
Posts: 85
Hi

I installed Swiftmailer 3 yesterday on PHP4 without too much issue (I'm a bit of a Noobie - hence the name!). There was a lot of jumping up and down and cheering I can tell you (I'm easily pleased).

I'd like to connect up the Batch Send with Attachment version to my MySQL DB to send out a Newsletter - what's the best way of doing that?

Dont suppose it's as simple as

Syntax: [ Download ] [ Hide ]
$recipients =& new Swift_RecipientList();

$recipients->addTo($recipient_emails);


Also - I noticed this thread: http://forums.devnetwork.net/viewtopic.php?t=64614 about an mid-send error issue, should I change that chunk of code in the version I'm running (if so... which file does it go in?).

Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 13, 2007 5:41 pm 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
You can probably just run the DB query, then when you loop through the resultset send each item from inside the loop. Just make sure you create the message object outside the loop.

Syntax: [ Download ] [ Hide ]
$result = mysql_query($query);



$message =& new Swift_Message( .... );

$message->attach(new Swift_Message_Attachment( .... ));



while ($row = mysql_fetch_assoc($result))

{

    $swift->send($message, $row["address"], $your_email);

}


You can also use the batchSend() method but it's exactly the same really... Proof :P

Syntax: [ Download ] [ Hide ]
//From the batchSend() method

                $ret = 0;

                foreach ($to->getTo() as $address)

                {

                        $ret += $this->send($message, $address, $from);

                }

                return $ret;


I have all kinds of plugins planned to build using the new plugin API over the next few months... including mailing list plugins (via DB), template plugins, throttlers....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 14, 2007 11:14 am 
Offline
Forum Commoner

Joined: Sun May 15, 2005 11:38 am
Posts: 85


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group