i am trying to send an email to many recipients.
it returns a blank page...
I guess it comes from the decorator or from the email field...
can someone tell me what's wrong there please?
is there any possibility to better the code so it doesnt load the server too much please?
thanks!
Code: Select all
//sends an email to clients having won points (uses tables: winners && clients)
$query = (" SELECT winners.id_winner, SUM(winning_numbers), clients.fname, clients.lname, clients.email
FROM winners, clients
WHERE winners.id_winner = clients.id_clients
AND mailsent = 0
GROUP BY id_winner ");
$result = mysql_query($query) or die('Query failed. ' . mysql_error());
while($row = mysql_fetch_array($result))
{
//Start Swift
$smtp =& new Swift_Connection_SMTP("smtp.xxxxx.com");
$smtp->attachAuthenticator(new Swift_Authenticator_LOGIN());
$smtp->setUsername("xxxxxx");
$smtp->setPassword("xxxxxxx");
$swift =& new Swift($smtp);
//Create the message
$message =& new Swift_Message("Dear {fname} {lname} you have won!", "Congratulations, you have played on http://www.xxxxxxx.com and won {points} points! Please log on xxxxxx.com and check if you can redeem your points for exclusive gifts. You can also convert your points into more chances to win excluse prizes offered by our partners! Have a great day!");
$message->setTo("undisclosed-recipients:;");
$replacements = array(
"$row['email']" => array("{fname}" => "$row['fname']", "{lname}" => "$row['lname']", "{points}" => "$row['SUM(winning_numbers)']*200")
);
//Load the plugin with these replacements
$swift->attachPlugin(new Swift_Plugin_Decorator($replacements), "decorator");
//Now check if Swift actually sends it
$swift->send($message, "$row['email']", "admin@xxxxx.com");
print "ok";
}
$swift->disconnect();