Response Error 451 Too Many Connections?
Posted: Thu Jul 12, 2007 3:56 am
Hi, I'm using swift version 2.1.16, php 4.4.4-8, SMTP connection.
Problem: Sometimes I get this message when sending emails with the code below. When I don't get this error, the email is delivered late (1-2 hour delay). This never happened before; only happened recently (about 1 week). My web host technical support said that the queue in mail system is full. But I wasn't sending a large amount of email, it was only a notification to 5-10 people that a form is approved.
Question:
1. Is there something wrong in my code / swift that could cause this? Or is this purely the SMTP server problem? Why is it happening recently? Why it said "There are currently too many connections from your IP/IP block"?
2. Why I also received email with subject: "0" and content: "0"?

Problem: Sometimes I get this message when sending emails with the code below. When I don't get this error, the email is delivered late (1-2 hour delay). This never happened before; only happened recently (about 1 week). My web host technical support said that the queue in mail system is full. But I wasn't sending a large amount of email, it was only a notification to 5-10 people that a form is approved.
Question:
1. Is there something wrong in my code / swift that could cause this? Or is this purely the SMTP server problem? Why is it happening recently? Why it said "There are currently too many connections from your IP/IP block"?
2. Why I also received email with subject: "0" and content: "0"?
Errors:
Array ( [0] => Array ( [num] => 0 [time] => 0.41449900 1184129232 [message] => MTA Error (Swift was expecting response code 250 but got 0): ) ) .
Log: Array ( [0] => Array ( [command] => [time] => 0.41429200 1184129232 [response] => 451 TOO_MANY_CONNECTIONS(451) - There are currently too many connections from your IP/IP block. Please try again later. ) [1] => Array ( [command] => HELO http://www.mydomain.com [time] => 0.41444000 1184129232 [response] => ) )
Code: Select all
class send {
function send($content=0,$subject=0,$destination=0){
global $mailer;
$smtpHost = "mydomain.com";
$mailer = new Swift(new Swift_Connection_SMTP($smtpHost));
$from = "email@mydomain.com";
$replyto = "me@mydomain.com";
$sendto = array($destination);
$_SESSION['content'] = $content;
$emailSubject = $subject;
#--- This part is to replace all image source and attach it to email
$parser = new HTML_SAXParser();
$parser->initFunc('changeImageSource');
$parser->parseString($_SESSION['content']);
if (!$mailer->hasFailed()) {
$mailer->addPart($_SESSION['content'], 'text/html');
$mailer->setReplyTo($replyto);
$success = $mailer->send(
array($replyto),
$from,
$emailSubject
);
$success = $mailer->send(
$sendto,
$from,
$emailSubject
);
$mailer->close();
if($success) return "Mail sent!";
}
else {
echo ("<br>Errors: ".print_r($mailer->errors, 1).". <br>Log: ".print_r($mailer->transactions, 1));
$mailer->close();
}
}
}
// $contentAll, $subject and $receiveremail is previously set
$send1 = new send;
$send1->send($contentAll,$subject,$receiveremail);