Catching mail server 'queue full' error message

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
Coomkeen
Forum Newbie
Posts: 2
Joined: Mon Mar 03, 2008 8:28 am

Catching mail server 'queue full' error message

Post by Coomkeen »

Hi,
I only have about 600 on my newsletter database, but the newsletter is often about 70k of html, and now that I'm going to use Swift and use multipart with a text version as well, it will be a lot bigger.

Previously, not using Swift, the mail server queue has filled up and thrown an error. So I've had to put a 6 second delay between each newsletter being sent.

Is there any way of catching just this 'queue full' error so the 'normal' delay can be short and be extended on error?

I've had the situation where a receiving server has been very slow.

Sorry I'm a bit green on all this stuff :?

One last quick point:
The anti-flood - is the "anti-flood" in quotes supposed to stay there, or is this a reference to something I should put in?
$swift->attachPlugin(new Swift_Plugin_AntiFlood(50, 10), "anti-flood");

Said I was green didn't I? :(

Ron
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Catching mail server 'queue full' error message

Post by Chris Corbyn »

PHP4 or 5?

The "anti-flood" should stay there, but you can change it to say something else if you wanted... it's just a key for looking that plugin back up again.
Coomkeen
Forum Newbie
Posts: 2
Joined: Mon Mar 03, 2008 8:28 am

Re: Catching mail server 'queue full' error message

Post by Coomkeen »

Thanks Chris,

I did finally (slow brain :( ) gather that it was just a name.

But what I really need to do is catch the mailserver 'queue full' or whatever the error is.
If I throw emails at the server too quickly, and especially if there's been slow response from receiving mailservers, I get an error.

If this could be detected, seperately from any other error, I could keep putting a delay in until the error disappeared. Sort of like a data handshake system.

Regards,
Ron

PS. PHP5
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Catching mail server 'queue full' error message

Post by Chris Corbyn »

Just wrap your send() call with a try/catch for a Swift_ConnectionException.

Code: Select all

try {
  $swift->send( ... );
} catch (Swift_ConnectionException $e) {
  $errorMessage = $e->getMessage();
  //do whatever....
}
The only way of distinguishing it from other types of SMTP error would be to preg_match() or strpos() for the string in the error message.
Post Reply