Page 1 of 1

Dynamic $recipients->addTo

Posted: Tue Oct 21, 2008 12:35 am
by poida_gtir
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);

Re: Dynamic $recipients->addTo

Posted: Tue Oct 21, 2008 6:38 pm
by poida_gtir
never mind im stupid had

Code: Select all

$recipients->addTo($sendToName, $sendToEmail);
instead of

Code: Select all

$recipients->addTo($sendToEmail, $sendToName);