uncaught errors under php4.3

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
japanitrat
Forum Newbie
Posts: 12
Joined: Sat May 12, 2007 10:34 pm

uncaught errors under php4.3

Post by japanitrat »

hi,

i am using swiftmailer for almost 3 months or something like that. i got version 3.2.1_4 running on a webserver.
it all worked fine. but something changed at the SMTP server which i have to connect to with swift.
although i did

Code: Select all

Swift_Errors::expect($e, "Swift_Exception");
i get the following output directly after instantiating a new swift-connection:
Fatal error:
Uncaught Error of type [swift_badresponseexception] with message [Expected response code(s) [250] but got response []]
@0 swift::swift() in /home/www/web4/web/tools/tE/mailer/index.php on line 42
@1 swift::connect() in /home/www/web4/web/tools/tE/mailer/swiftmailer/Swift.php on line 111
@2 swift::handshake() in /home/www/web4/web/tools/tE/mailer/swiftmailer/Swift.php on line 245
@3 swift_connection_smtp::postconnect() in /home/www/web4/web/tools/tE/mailer/swiftmailer/Swift.php on line 300
@4 swift_connection_smtp::runauthenticators() in /home/www/web4/web/tools/tE/mailer/swiftmailer/Swift/Connection/SMTP.php on line 341

in /home/www/web4/web/tools/tE/mailer/swiftmailer/Swift/Errors.php on line 99
albeit I did the exception workaround mentioned in the docs, i am not able to process any further php-line after that fatal error.

first of all: what is this error about? i used that smtp-server some weeks with the same swift-version on the same server, but somehow, now i encounter that error.
secondly: how can i catch that error?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

The connection is not starting so you cannot go any further. The PHP4 exception handling is a little flaky at best since PHP4 is not supposed to handle exceptions and they don't "bubble" like PHP5 exceptions. Have you double checked your connection information?
japanitrat
Forum Newbie
Posts: 12
Joined: Sat May 12, 2007 10:34 pm

Post by japanitrat »

as I said, i did not change the connection-settings to that server. i used the same login to test it with a standard mail-client and it worked. either my webserver is blacklisted on that smtp-server, or it has something to do with popbeforeauth.

but i cant get a more detailed error description, because PHP dies after that connection error. although i really enjoy swiftmailer, i wonder why it doesnt allow custom error tracing in php4. I mean, that script must do some further reporting and other steps before it is allowed to die. i need to log that. really.
i mean it's okay, if swift throws that error and denies any further action on that instance, but hellya, does it have to kill the whole script after encountering the connection-failure? what is this Swift_Errors::expect about, if i can't receive and process that error in $e ?
please help me.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Your host are probably blocking the connection, or your not in the designated list of hosts allowed to connect to that SMTP server ;)

What does this show? (replacing $server with the actual server you're connecting to of course ;))

Code: Select all

$sock = fsockopen($server, 25, $errno, $errstr, 30);
echo "Socket contents";
var_dump($sock);
echo "Error number = " . $errno . "<br />";
echo "Error message = " . $errstr . "<br />";
Did you also say you're using PopBeforeSmtp ? This is a special case with Swift, it doesn't do this automatically like the other authenticators ;)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

japanitrat wrote:i mean it's okay, if swift throws that error and denies any further action on that instance, but hellya, does it have to kill the whole script after encountering the connection-failure? what is this Swift_Errors::expect about, if i can't receive and process that error in $e ?
please help me.
I know, it's the great big ugly thing I don't like about the PHP4 version. I don't really consider the PHP4 version to be the "proper" version, it's just something I convert from PHP5 code so PHP4 developers can use it :( The PHP5 version is the main version and I've used exceptions quite extensively for program flow which makes it extremely difficult to adapt to PHP4. There's really no way around it because "errors" in PHP4 don't bubble like exceptions so it's difficult to track exactly where the first occurence comes from and it's impossible to "jump" from one block of code to another like with try/catch. The closest I've (and anyone else for that matter) has been able to come up with is the Swift_Errors class which all errors proxy through, but it still can't drive program flow in the same way as exceptions.

Support for PHP4 is ending on February 5th however so I don't plan on reversing all my PHP5 code (which is rock solid) in order to make the PHP4 branch better ;)

http://www.swiftmailer.org/gophp5/
japanitrat
Forum Newbie
Posts: 12
Joined: Sat May 12, 2007 10:34 pm

Post by japanitrat »

the code you've mentioned returns error=0 with message="".
actually i do not know, if that server enabled popbeforesmtp now, but it didnt some weeks ago. I only wanted to state, that this could be an alternative.

i appreciate using php5, but this time on this server, i can only use php4. I have to admit that i am not that pro in PHP. i was thinking about disabling that line, that kills the php-script on the error, but i do not see, where it happens. where does it halt?
Post Reply