Dynamic $recipients->addTo
Posted: Tue Oct 21, 2008 12:35 am
Just wondering if any one has any advice on adding recipients dynamically. Below is what i have tried might give you a better idea of what im trying to do. Name and email stored in a database want to build the list dynamically and send. My database query works and the swiftmail works with manually entered addresses. Any help would be great.
Code: Select all
$recipients =& new Swift_RecipientList();
//Gets recipient information
$db = new EmailAddress();
if ($db->IsError())
{
$msg = "<div class=\"error\"><strong>ERROR:</strong> Cannot connect to database</div>";
}
else
{
$result = $db->getAllActive($mailingListID);
while($row = $db->FetchArray($result))
{
$sendToName = $row['name'];
$sendToEmail = $row['email'];
$recipients->addTo($sendToName, $sendToEmail);
}
}
$db->FreeResult($result);