Page 1 of 1
Preventing "Uncaught Exception"
Posted: Thu Jan 24, 2008 5:41 am
by VinceP
Hi,
It's been a late night, and for the life of me I can't figure out how to resolve the error analysis for Swift.
I include Swift and attempt to send an e-mail using code such as:
Code: Select all
if (class->swiftmail($fields)) { // Do something }
This obviously seems to work when successful, but when I deliberately fudge the authentication, Swift throws out the following:
Code: Select all
Fatal error:
Uncaught Error of type [swift_connectionexception] with message [Authentication failed using username 'blah@domain.com' and password '********']
Can I suppress these errors and just have Swift throw a return status of 0 instead? I'm using PHP4 if it makes any difference. Thanks.
Re: Preventing "Uncaught Exception"
Posted: Thu Jan 24, 2008 5:53 am
by Chris Corbyn
It's the one bit I hate the most about the PHP4 version and the reason why in 11 days time I'm dropping support for it
The library is developed under PHP5 and uses exceptions quite heavily. Exceptions don't exist in PHP4 and there's no "equivalent" in terms of program flow. Since I didn't want to maintain two completely different sources (i.e. in terms of logic) I came up with this -- flaky at best -- solution:
http://www.swiftmailer.org/wikidocs/v3/misc/php4errors
I'd suggest upgrading to PHP5 asap considering I'm not supporting it any longer, nor are PHP/Zend themselves. Cutoff date is Feb 8th for Swift. The old version will remain available but bugfixes and new versions will be for >= PHP 5.2 only.
Re: Preventing "Uncaught Exception"
Posted: Thu Jan 24, 2008 6:31 am
by VinceP
Version preference aside, it's not an option to upgrade to PHP5 on this server unfortunately, so I'm stuck with it
I read that documentation page before I posted, and to be honest it had me a little confused. Maybe I'm just tired
What's "theMethod()" all about?
Re: Preventing "Uncaught Exception"
Posted: Thu Jan 24, 2008 2:32 pm
by Chris Corbyn
theMethod() is just pseudo code.
For your connection failure, try this:
Code: Select all
Swift_Errors::expect($e, "Swift_Exception");
$swift = new Swift( ... );
if (!is_null($e)) {
//error occured
} else {
Swift_Error::clear("Swift_Exception");
}
Your host should feel pressured to upgrade if enough people ask

PHP 4 officially died in December 2007 so your host will no longer get support for it, nor security updates.
Re: Preventing "Uncaught Exception"
Posted: Thu Jan 24, 2008 3:31 pm
by VinceP
Yep, I know PHP4 has died, but it's a control panel solution so not upgradeable until they change their source packages. Speaking as someone who has worked in the hosting industry for over 7 years, I know forcing your customers to upgrade can cause more problems than not upgrading to begin with. You'd be shocked at how many of them use 4+ year old scripts that contain deprecated functions that don't work on upgraded systems. Always a good idea to keep an old server or 2 around for cases like that, simply because they don't want to get their code rewritten
Anyway, back to the subject at hand....
Here's what I currently have:
Code: Select all
Swift_Errors::expect($e, "Swift_Exception");
$smtp =& new Swift($conn);
$subject = "Subject"
$body = "Random body";
$message =& new Swift_Message($subject, $body);
$result = $smtp->send($message, new Swift_Address($to, $to), new Swift_Address($from, "Company Name"));
With your new line added, I now get a different error:
Code: Select all
Fatal error:
Uncaught Error of type [swift_badresponseexception] with message [Expected response code(s) [250] but got response [530 5.5.1 Authentication Required m34sm1737189waf.48]]
I assume it doesn't matter that I'm not checking for errors immediately after creating the Swift instance? I obviously need to set the message content, so figured I could check after attempting to send?
Still haven't slept, so sorry if I'm completely off the ball here

Re: Preventing "Uncaught Exception"
Posted: Sat Jan 26, 2008 7:57 am
by VinceP
Any ideas, Chris?
Re: Preventing "Uncaught Exception"
Posted: Sun Jan 27, 2008 12:15 pm
by VinceP
Just FYI, I decided to scrap SwiftMailer completely. Your lack of response to this thread towards the end, despite your recent activity in other threads, was the primary factor. I will, also, not be using SwiftMailer in any future projects.
If you, personally, don't want to support the PHP4 version of SwiftMailer because you feel that PHP4 is "dead", then I can only suggest you remove it from your website and/or put a disclaimer saying that you refuse to support it, and people should use PHP5 version instead. Ignoring the thread, though, completely destroys your credibility. Understandably I can't have my projects use something which the author appears to not want to support in certain instances.
Regardless of your personal views on the "expiration" of PHP4, people will continue to use it (and perhaps the PHP4 version of SwiftMailer) for many years to come. If you don't want to support it *now*, then do something about it.
Re: Preventing "Uncaught Exception"
Posted: Sun Jan 27, 2008 5:31 pm
by Chris Corbyn
I'm sorry that my volunteer efforts leave a bad taste in your mouth. The lack of respect shown by people who rant at me like you have just done does not give me a great feeling about continuing which this project -- though I will because the majority of people appreciate the (quite literally) thousands of hours development that has gone into this.
Just for the record, I wasn't ignoring you, I read every thread that gets posted here it's just that I don't always have an immediate answer to everything.
In future I suggest you show some respect to the developers of the open source software you freely download and freely request support for.
Good day

Re: Preventing "Uncaught Exception"
Posted: Sun Jan 27, 2008 6:11 pm
by Christopher
VinceP wrote:Just FYI, I decided to scrap SwiftMailer completely. Your lack of response to this thread towards the end, despite your recent activity in other threads, was the primary factor. I will, also, not be using SwiftMailer in any future projects.
I read the thread and it looks like you got answers within hours of each posting.
VinceP wrote:If you, personally, don't want to support the PHP4 version of SwiftMailer because you feel that PHP4 is "dead", then I can only suggest you remove it from your website and/or put a disclaimer saying that you refuse to support it, and people should use PHP5 version instead. Ignoring the thread, though, completely destroys your credibility. Understandably I can't have my projects use something which the author appears to not want to support in certain instances.
So you are complaining that someone will not provide free help for you to do your job? Just because you are not able to get the PHP4 version to work does not mean that many other may not find it useful. In fact by your own argument, Chris should not remove the PHP4 version for just the same reasons you choose to "keep old servers" around. Your apparently poor choice of control panel software does not reflect on SwiftMailer or Chris.
VinceP wrote:Regardless of your personal views on the "expiration" of PHP4, people will continue to use it (and perhaps the PHP4 version of SwiftMailer) for many years to come. If you don't want to support it *now*, then do something about it.
Those views are not "personal" views. PHP4 is no longer supported. The PHP4 versions of many PHP applications are also no longer supported. Your opinion that free PHP4 software should be supported for you is the only "personal view" I see here.
You have been inexcusably rude to someone who is kind enough to provide free software and support. I think you should apologize.
Re: Preventing "Uncaught Exception"
Posted: Sun Jan 27, 2008 9:36 pm
by Selkirk
How much does a swift mailer support contract cost again?

Re: Preventing "Uncaught Exception"
Posted: Sun Jan 27, 2008 10:04 pm
by John Cartwright
arborint wrote:You have been inexcusably rude to someone who is kind enough to provide free software and support. I think you should apologize.
Agreed. That was selfless of you. However, it's your loss if you want to drop support for the best php email library available.
Re: Preventing "Uncaught Exception"
Posted: Tue Jan 29, 2008 1:23 am
by Benjamin
Keep up the good work Chris. I think people forget that there's a person on the other side of the keyboard sometimes.