Problem with Addto using batchsend and mysql data
Posted: Mon Jan 25, 2010 5:58 am
Hi Guys,
I am new to the forum and please forgive me in advance if the answer is somewhere in here (but could not find it).
I am using swiftmailer version 4, which is potentially a very usefull tool for me. However, I am stuck with sending a newsletter to a bunch of people. If I hardcode the email addresses everything is going fine. But I am actually using a database to retreive email addresses. I actually thought I could simply loop to retreive these using the "addto" function. Please see my code below :
By the way, if I try this code below, email adresses within the database echo real fine.
Can anyone help ?
Thanks in advance...
I am new to the forum and please forgive me in advance if the answer is somewhere in here (but could not find it).
I am using swiftmailer version 4, which is potentially a very usefull tool for me. However, I am stuck with sending a newsletter to a bunch of people. If I hardcode the email addresses everything is going fine. But I am actually using a database to retreive email addresses. I actually thought I could simply loop to retreive these using the "addto" function. Please see my code below :
Code: Select all
setFrom(array('something@somedomain.com' => 'Newsletter'))
->setSender('something@somedomain.com')
->setReturnPath('something@somedomain.com')
->setBody('message')
;
[color=#BF0000]// loop to add new recipient, this doesn't work !!![/color]
while ($donnees3 = mysql_fetch_array($retour3))
{
$message->addTo($donnees3['email']);
}
[color=#BF0000]//this works perfectly !![/color]
$message->addTo('something@somedomain.com');
//Send the message
$numSent = $mailer->batchSend($message);
By the way, if I try this code below, email adresses within the database echo real fine.
Code: Select all
while ($donnees3 = mysql_fetch_array($retour3))
{
echo $donnees3['email'] ;
}Thanks in advance...