Month: July 2012

Sending mail with PHP, PEAR & Godaddy

Sending mail with PHP, PEAR & Godaddy

I created a very small php file to send email messages which would get called from my app. Everything worked just fine testing locally, then I deployed it to my godaddy account and it wouldn’t work. If you try to goggle specific topics for info on getting something like PEAR PHP mail to work on godaddy you’ll find it hard to come by. Hence this post.

The forum help from godaddy is OK, but more often than not they tell you why you’re having issues. So you still have to figure out how to fix it (which is good in some ways as well – don’t learn unless you figure it out yourself sometimes).

So this is the code that will work when you test locally and as it comes from my machine the mail request gets seen as a client connection (same as say outlook etc) and not as a web server. This is why you need to change the code when you deploy to a web server.

";
$to = "Mrs Jones ";
$subject = "What's up";
$body = "Hi,nnHow are you? What is happening";
 
 $host = "smtpout.secureserver.net";
 $username = "[email protected]";
 $password = '************';
 
 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'auth' => true,
     'username' => $username,
     'password' => $password));
 
 $mail = $smtp->send($to, $headers, $body);
 
 if (PEAR::isError($mail)) {
   echo("

" . $mail->getMessage() . "

"); } else { echo("

Message successfully sent!

"); } ?>

So here is the code that will work when you deploy it to your server on godaddy, this may well be the same as other server providers.

";
$to = "Mrs Jones ";
$subject = "What's up";
$body = "Hi,nnHow are you? What is happening";

$headers = array (
    'From' => $from,
    'To' => $to,
    'Subject' => $subject);

 $smtp = Mail::factory('smtp' );

 $mail = $smtp->send($to, $headers, $body);
 
 if (PEAR::isError($mail)) {
   echo("

" . $mail->getMessage() . "

"); } else { echo("

Message successfully sent!

"); } ?>

So as you can see I’ve totally removed the host, username, password. This will work providing you have the following lines inside you php.ini or php5.ini file.


SMTP = relay-hosting.secureserver.net
smtp_port = 25

If you do try and use the first piece of code on the webserver it will warn you about being unable to connect. for example,
Warning: fsockopen() [function.fsockopen]: unable to connect to {some ip address} (Connection refused) in /usr/local/lib/php/Net/Socket.php on line 108
unable to connect to smtp server.

[ad name=”ad-1″]

Stop the mobile ActionBar from transitioning

Stop the mobile ActionBar from transitioning

I was creating a mobile AIR app and the app was to have an ActionBar at the top and depending on the view that was about to get pushed I didn’t want the ActionBar to have a transition effect. Sounds like a simple request, nope, no can do…

So after a bit of digging into the various classes ( mainly the ViewTransitionBase ) I came across what needed to be changed 🙂 but its a mx_internal so use the following fix with caution.

All of the various effects check the actionBarTransitionMode while they create the effects.  Its just that the actionBarTransitionMode is always set to ACTION_BAR_MODE_FADE_AND_SLIDE and never changes from that value. What’s more the actionBarTransitionMode is a mx_internal  variable so you can’t just call it yourself when creating a new effect.

So here is the fix.

  1. Extend whatever effect you wish to use. e.g. SlideViewTransition
  2. add the following lines to your extended class import import mx.core.mx_internal; and use namespace mx_internal;
  3. Either inside your constructor set the value (if you don’t wish to change it at runtime) or create a setter to modify the value actionBarTransitionMode
Possible values are (these can be found in the ViewTransitionBase class),

ACTION_BAR_MODE_FADE:String = “fade”;

ACTION_BAR_MODE_FADE_AND_SLIDE:String = “fadeAndSlide”;

ACTION_BAR_MODE_NONE:String = “none”;

In my case I set it to ACTION_BAR_MODE_NONE as I didn’t wish to have any transition on the ActionBar.

[ad name=”ad-1″]

Sencha touch – IDE??

Sencha touch – IDE??

Being a Flex dev for a number of years and deciding that its about time I try out something new and seeing all the hype surrounding Sencha touch I spent a week too two weeks looking at it. It comes across like it is aiming at a very similar market to Flex so I was quite excited about trying it.
Version 2 was just out and it had some path issues for installing etc but the guys at Sencha appeared to be working very hard to get rid of all the little issues and these are now resolved. So I tried to find an IDE/plugin or similar that would allow me to code in the same way as I do Flex/Actionscript.

I tried Netbeans, Webstorm, Aptana, various Eclipse with javascript plugins and quite a few others that I can’t quite remember but NONE of them gave me a similar experience as Flex/Flashbuilder. As in code completion, catching errors etc. I know that javascript is really slack (in a similar way that AS2 was) but when you try something for the first time a good IDE is worth its weight in gold for helping to learn. The Sencha docs are also really good, but why should I have to keep looking at them to see what features are available for the components I want to use.

As I was a real newbie with javascript & Sencha I decided to go to a boot camp & conference on Sencha to speed up my learning, thinking that I’d see what tools they used as there must have been something out there which would make creating Sencha apps feel like programming and the answer was NO!

I did find out how much Chrome is a great tool for web programmers, but it really doesn’t cut it compared to normal development. Brackets from Adobe also sounds like its getting there for web/Javascript development, but its not aimed at Sencha.

 

SO, after the courses and testing of Sencha I decided that I’d NOT touch it again until it had a decent IDE or plugin for an IDE. Well it looks like the guys at Sencha have listened and they have a beta out for an Eclipse plugin. http://t.co/PYpC1WJf  Its a private enrolement at the moment, but fingers crossed 🙂

 

I said at the time that I didn’t think Sencha wasn’t quite ready, but with an IDE and Sencha Architect (which I really liked, its like a working version of Flashbuilder in design mode) I’m willing to give it another go. Here’s hoping they let me in to give it a test.

[ad name=”ad-1″]