pinz Posted December 7, 2011 Share Posted December 7, 2011 I got a problem with Zend mail - addTo doesn't want to add addresses from an array, thou it does send with a single recipient from another script. It says 'bad syntaxys of recipient'. Here is code part: PHP Code: // Setting recipient $q = mysql_query("SELECT * FROM emailscategoriesmap WHERE fk_categoriesId='".$row['fk_categoriesId']."'"); while($r = mysql_fetch_assoc($q)) { $qu = mysql_query("SELECT * FROM emails WHERE emailsId='".$r['fk_emailsId']."' AND emails_status='aktiv'"); $res = $qu; $e = mysql_fetch_assoc($res); $email = mysql_real_escape_string($e['address']); $mail->addTo($email, $email); echo "$email<br /> <pre>"; print_r($e); echo "</pre>"; } $mail->addTo('mail@hotmail.com', 'mymail'); // Setting mail subject $mail->setSubject($row['name']); // Sending mail $setLoggetQuery = mysql_query("UPDATE newsletter SET logget='1' WHERE newsletterId='".$row['newsletterId']."'"); if(!$setLoggetQuery) { echo "<span>Fejl!Nyhedsbrev blev ikke sendt.</span>"; } else { $mail->send($transport); echo 'Mail was sent successfully.'; } } and i know for sure that the print_r i call for final query, shows the proper addresses, it just fails to add them one by one with addTo pls help needed Link to comment Share on other sites More sharing options...
boen_robot Posted December 7, 2011 Share Posted December 7, 2011 mysql_real_escape_string() needs to be called when you use a value as part of a query. Nowhere else.The email address probably contains a character that is escaped by it, rendering the email invalid. BTW, this "$res" variable is redundant.Try it like this: $qu = mysql_query("SELECT * FROM emails WHERE emailsId='".$r['fk_emailsId']."' AND emails_status='aktiv'");$e = mysql_fetch_assoc($qu);$email = $e['address'];$mail->addTo($email); Link to comment Share on other sites More sharing options...
pinz Posted December 7, 2011 Author Share Posted December 7, 2011 yaaay, it works now. Thanks! Link to comment Share on other sites More sharing options...
pinz Posted December 8, 2011 Author Share Posted December 8, 2011 doesn't want to work again...same problemany other suggestions on how can i add usermails from an array with addTo? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 8, 2011 Share Posted December 8, 2011 Print out the email before you send it to the function to make sure it's in the correct format. If it's in the correct format then it should work. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.