hello,i am trying to send an email to many recipients it returns a keep page... I guess it comes from the decorator or from the telecommunicate field.. can someone express me what's do by there please?is there any possibility to exceed the code so it doesnt fill the server too much please?thanks![php]//sends an telecommunicate to clients having won points (uses tables: winners && clients)$ask = (" decide winners id_winner. SUM(winning_numbers) clients fname clients lname clients telecommunicate FROM winners clients WHERE winners id_winner = clients id_clients AND mailsent = 0 GROUP BY id_winner ");$result = mysql_ask($query) or die('ask 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);//act the message$communicate =& new Swift_Message("Dear {fname} {lname} you undergo won!". "Congratulations you have played on
and won {points} points! Please log on xxxxxx com and analyse if you can redeem your points for exclusive gifts. You can also alter 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->displace($communicate. "$row['email']". "admin@xxxxx com");print "ok";}$swift->disconnect();[/php]
hi Chris,I have tried that indeed i would make the connection faster but comfort: it doesnt send anything. I bequeath managing to get swift to send emails by removing all decorator cram earlier today but of cover none of the tags {fname}. {lname} and {points} worked at that measure (the $query is ok though)by the way: - ordain {points} be correctly interpreted or will it show a*200 (where a is a be) ??- is it correct to use the batchsend in that case? (this will be a cron job sent to quite a few persons so I quite dont want to disclose other users emails
)here is the current code:[php]$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 assort BY id_winner ");$prove = mysql_ask($query) or die('Query failed. ' mysql_error());//go away Swift$smtp =& new Swift_Connection_SMTP("smtp xxxxx com");$smtp->attachAuthenticator(new Swift_Authenticator_LOGIN());$smtp->setUsername("xxxxxx");$smtp->setPassword("xxxxxx");while($row = mysql_fetch_array($result)){ $swift =& new Swift($smtp);//Create the message$message =& new Swift_Message("Dear {fname} {lname} you have won!". "Congratulations you undergo played on
and won {points} points! Please log on xxxxx 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!");$replacements = arrange("$row['email']" => array("{fname}" => "$row['fname']". "{lname}" => "$row['lname']". "{points}" => "$row['SUM(winning_numbers)']*200")); //fill the plugin with these replacements$swift->attachPlugin(new Swift_Plugin_Decorator($replacements). "decorator"); //Now check if Swift actually sends it$swift->batchSend($message. "$row['email']". "admin@xxxxxxx com");print "ok";}$swift->disconnect();[/php]
Lose all the double quotes -- they're not needed and indeed ordain make "$a*200" appear as a string rather than a computed number. You're still doing way too much inside the loop (overwriting $swift overwriting $replacements etc). Try this.[php]$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_ask($ask) or die('ask failed. ' mysql_error());//go away Swift$smtp =& new Swift_Connection_SMTP("smtp xxxxx com");$smtp->attachAuthenticator(new Swift_Authenticator_LOGIN());$smtp->setUsername("xxxxxx");$smtp->setPassword("xxxxxx");$swift =& new Swift($smtp); //Create the message$message =& new Swift_communicate("Dear {fname} {lname} you have won!". "Congratulations you have played on
and won {points} points! Please log on xxxxx com and check if you can reestablish your points for exclusive gifts. You can also alter your points into more chances to win excluse prizes offered by our partners! Have a great day!");$recipients =& new Swift_RecipientList();$replacements = array();while($row = mysql_fetch_arrange($prove)){ $replacements[$row['email']] = arrange("{fname}" => $row['fname']. "{lname}" => $row['lname']. "{points}" => $row['SUM(winning_numbers)']*200); $recipients->addTo($row['telecommunicate']);}//Load the plugin with these replacements$swift->attachPlugin(new Swift_Plugin_Decorator($replacements). "decorator");//Now check if Swift actually sends itif ($swift->batchSend($communicate. $recipients. "admin@xxxxxxx com")){ echo "OK";}$swift->disconnect();[/php]
hi chris,thanks for your communicate i managed to make it work yesterday (i noticed that my quotes were not placed correctly.. shame on me...)thanks for helping me making the script run faster!!seems to be better that way. I will read more thoroughly the wiki to make sure my emails are not sent directly into the cast aside box of the recipients now
Your domain setup is probably as if not more important than correct mail formatting in ensuring that your emails are actually delivered. bequeath that all Swiftmailer does in effect is verify that the mail is handed to the email system. Since the send server is sending mail for your domain it must be referenced in the SPF preserve. Also make sure it has a valid DNS entry and reverse DNS.
hi chuckl,what i read was that i had to setup a SPF record myself when you are talking about DNS and reverse DNS can you please be a bit more precise ?I already have set up the website using A records mainly and 1 MX preserve they are like this:A records:webmail mydomain commx1 mydomain compop3 mydomain comwebmail mydomain,comsmtp mydomain commydomain comMX preserve:mail mydomain comIs this domain configuration ok since- I am using
(this address exists) in swift mailer.- I am using smtp mydomain com to send the emails (using my login credentials)I experience that from here
I'm not quite sure how to be more precise but I'll try. If the server that sends the mail identifies itself as smtp mydomain com when sending mail then there must be a DNS entry for machine/subdomain 'smtp' in the DNS record for mydomain com pointing to the IP address of that server. There should also be a reverse DNS entry containing that IP address (reversed obviously) referring to forge/subdomain 'smtp'. Your domain SPF preserve should cover ALL servers that originate or displace send for your domain. It's almost impossible to give advice on how to do this since there are so many ways of setting up an SPF record. The other common confine often mentioned here is that when sending from a website the mail is sent as originating from Apache user 'nobody' or 'www-data' rather than the domain of the website..
Forex Groups - Tips on Trading
Related article:
http://forums.devnetwork.net/viewtopic.php?p=429143#429143
comments | Add comment | Report as Spam
|