Error: [421 too many messages in this connection]
Posted: Mon Jan 14, 2008 9:02 pm
Hi!
I got this error when sending the emails to a list of clients from a database. Am I supposed to close and re-open the Swift connection after XX number of emails are sent out?
This is how I am sending the messages:
What is the problem with my sending? By the way, I got the error message exactly after sending 1000 emails out.
Thanks a lot for the help.
I got this error when sending the emails to a list of clients from a database. Am I supposed to close and re-open the Swift connection after XX number of emails are sent out?
This is how I am sending the messages:
Code: Select all
while ($row = mysql_fetch_array ($result)){
$recipient_id = $row['recipient_id'];
$list_id = $row['list_id'];
$replacements = array($row["recipient_email"] => array("{UNSUBSCRIBE_EMAIL}" => $row["recipient_email"],
"{LIST_ID}" => $row["list_id"],
"{FIRST_NAME}" => $row["recipient_first_name"],
"{LAST_NAME}" => $row["recipient_last_name"]));
//Load the plugin with these replacements
$swift->attachPlugin(new Swift_Plugin_Decorator($replacements), "decorator");
//Replace content in the $parts, this will still affect $message due to the references
//$htmlPart->setBody(str_replace("{UNSUBSCRIBE_EMAIL}", $row["recipient_email"], $html_body));
//$textPart->setBody(str_replace("{UNSUBSCRIBE_EMAIL}", $row["recipient_email"], $text_body));
//set the number of messages per minute
$throttler->setEmailsPerMinute(100);
$swift->attachPlugin($throttler, "throttler");
if ($swift->send($message, $row['recipient_email'], new Swift_Address($message_from_email, $message_from_name))){
//echo "Sent";
}
else {echo "Failed";}
Thanks a lot for the help.