Page 1 of 1

[FIXED] mass emailing, fatal error mid-send

Posted: Mon Mar 05, 2007 4:18 pm
by zamiwas
(sorry to bother you) Using php4, swift3

I'm using Swift to send say 3 emails to forum members (1000+).
Basically midway through the first email (after 5 min) I get:

Fatal error: Uncaught Error of type [swift_connection_exception] with message [Expected response code(s) [250] but got response 0]

Its hard to test because some users get the email, others dont.
The recipient array is fine, set_time_limit(0) and ignore_user_abort().
And phpBB's mass emailer sent 1000 emails fine, so I don't know the problem.

Thanks for any suggestions, im very unknowing

Posted: Mon Mar 05, 2007 6:06 pm
by Chris Corbyn
I'm looking into this from somebody else's bug report too thanks :) It should never trigger that error in theory but it seems like the connection is dropping at some point.... either way, I will address it.

Posted: Tue Mar 06, 2007 3:22 am
by Chris Corbyn
Hi, was this from a batchSend() call by any chance rather than a send() call?

I think I've got it nipped, but if it wasn't from calling batchSend() then I'll need to keep looking.

Cheers,

Chris

Posted: Tue Mar 06, 2007 3:03 pm
by zamiwas
Yep, it was with batchSend()

Posted: Tue Mar 06, 2007 3:20 pm
by Chris Corbyn
Brilliant :)

EDIT | Would you like to give this one a go and see what it says? :)

http://www.w3style.co.uk/~d11wtq/trunk.zip [1.4MB]

It will extract to a folder called "trunk" containing php4 and php5 subdirectories. It's potentially the release I'll be making in a few hours unless it's still not working for you.

Posted: Tue Mar 06, 2007 3:51 pm
by zamiwas
Fatal error: :cry:
Uncaught Error of type [swift_connection_exception] with message [Expected response code(s) [250] but got response []]
@0 swift::batchsend() in /home/promed/www/html/Swift/mass_emailer.php on line 119
@1 swift::send() in /home/promed/www/html/Swift/lib/Swift.php on line 539
@2 swift::command() in /home/promed/www/html/Swift/lib/Swift.php on line 432

could be something on my part?

Posted: Tue Mar 06, 2007 4:03 pm
by Chris Corbyn
Darn! :(

I know what's causing it too... I just want it to actually tell people that!. There's actually an error being generated which will says something like "There was a problem reading the SMTP response at line x. The response so far is [yyyy]". That is of type Swift_Connection_Exception and because PHP4 doesn't do exceptions, it's being caught by the wrong expect() call in Swift (i.e. it's ambiguous). That's my fault (in PHP5 it would never happen)... all I need to do is define a specific type of exception for bad response codes and this will be solved. I should have thought of that before! :)

Sorry, I'm thinking out loud again....

How many emails is it sending before giving up? Have you checked that your server allows you to send 1000 (or even more than 100 for that matter) at any one time? I'll have to sort out that error though... some text would be useful ;)

Posted: Tue Mar 06, 2007 4:36 pm
by Chris Corbyn
This one?

http://www.w3style.co.uk/~d11wtq/trunk2.zip (extracts to a folder called "trunk")

Posted: Tue Mar 06, 2007 5:08 pm
by zamiwas
~! amazing! how'd you fix it?
THANKS

Posted: Tue Mar 06, 2007 5:23 pm
by Chris Corbyn
Brilliant :)

It was a simple matter of making the identity of a particular exception different from that of another. PHP4 doesn't have support for try/catch & exceptions, so I rolled my own implementation I aptly dubbed to be a "hackaround" when I converted the library to PHP4. It is type-aware like exceptions are, and it does throw error objects around, but it's just not too clever at knowing which exception you wanted when two are thrown in sequence. I created a new type for a specific purpose and now we're good :)

In code, I changed this:

Code: Select all

Swift_Errors::expect($e, "Swift_ConnectionException");
	if (!$e) //blah
	if (!$e) //blah
if (!$e) {
	//nothing caught
	Swift_Errors::clear("Swift_ConnectionException");
} else {
	//Exception caught so we failed
}
To this:

Code: Select all

Swift_Errors::expect($e, "Swift_BadResponseException");
	if (!$e) //blah
	if (!$e) //blah
if (!$e) {
	//nothing caught
	Swift_Errors::clear("Swift_BadResponseException");
} else {
	//Exception caught so we failed
}