Sending Email with PHP, PHPMailer and Amazon SES by: John Howard

January 21st, 2012

Sending email with Amazon’s SES is easy. To get started you’ll need an AWS account with SES sending enabled.

This example uses PHPMailer and builds on some PHPMailer examples.


    require_once('PHPMailer/class.phpmailer.php');
    $to         = "someone@foo.com";
    $from       = "youremail@foo.com";
    $subject    = "a test subject";
    $body       = "email body content goes here";

    $mail       = new PHPMailer();
    $mail->IsSMTP(true);            // use SMTP

    //$mail->SMTPDebug  = 2;        // enables SMTP debug information (for testing)
                                    // 1 = errors and messages
                                    // 2 = messages only
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->Host       = "tls://email-smtp.us-east-1.amazonaws.com"; // Amazon SES server, note "tls://" protocol
    $mail->Port       = 465;                    // set the SMTP port
    $mail->Username   = "YourSESSMTPUserName";  // SES SMTP  username
    $mail->Password   = "YourSESSMTPPassword";  // SES SMTP password

    $mail->SetFrom($from, 'First Last');
    $mail->AddReplyTo($from,'First Last');
    $mail->Subject    = $subject;
    $mail->MsgHTML($body);
    $address = $to;
    $mail->AddAddress($address, $to);

    if(!$mail->Send()) {
      echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
      echo "Message sent!";
    }

For an example of using SSL with SES and PHPMailer see https://forums.aws.amazon.com/thread.jspa?threadID=82812

php

Set Custom Activity Result on Back Button Click by: John Howard

May 28th, 2011

The android Activity documentation for setResult() states: “to set the result that your activity will return to its caller.” So why does setResult(MyActivity.MY_RETURN_VALUE) not return your custom value to the calling activity’s onActivityResult() event? To return a value other than RESULT_CANCELED you need to Read more…

Android Coding

Installing Nginx with php-fpm on Ubuntu 10.04 and 11.10 by: John Howard

January 9th, 2011

Nginx with php-fpm is a high performance alternative to the traditional apache PHP combination. In my experience, nginx with php-fpm uses significantly less memory, in some cases only a third of the memory required to run apache and PHP. For this example a fresh install of Ubuntu 10.04 desktop was used. Starting with a fresh install of 10.04, you should be able to follow these steps and finish with a working nginx with php-fpm box.

Update: These instructions were recently confirmed to work with ubuntu 11.10 (AWS ami-a562a9cc) and PHP 5.3.8.

Open a terminal and update your install.


sudo apt-get update
sudo apt-get upgrade

Read more…

linux, nginx, php , ,

Android Selected State ListView Example by: John Howard

December 5th, 2009

Sometimes we need to maintain the selected position in a list. This example was taken from a real-world, off-road application where users interact with the application in a bumpy environment and need a fool proof way of changing the sort order of items in a list. When an item is clicked in the list and that row becomes the selected row as indicated by a different background color. The user can then change the position of the selected row using the Move Up and Move Down buttons on the screen.

Here’s a screen-shot of this example running in the emulator.

Android Selected State List Example

Android Selected State List Example


Read more…

Android Coding ,

Back Road Cycling Hardwick, Greensboro and Woodbury Vermont by: John Howard

December 5th, 2009

I spent three great days in August visiting family and cycling in the Hardwick, Vermont area. The weather was perfect, three consecutive days with no rain, maybe the longest dry streak of 2009 for the North East Kingdom. My brother Spencer let me borrow his hardtail mountain bike which I setup with Dura Ace SPD-SL pedals. Not exactly a common sight on mountain bikes but it worked out well for this trip. Also acquired a UVM Cycling jersey for the trip. I had no idea UVM Cycling was so successful for the 2008-2009 season, first and second at the Collegiate National Cycling Championships. Catamounts on bikes..why not?
Read more…

Food, cycling , ,

Upgrading from Android 1.1 SDK to 1.6 SDK by: John Howard

October 7th, 2009

I recently upgraded from Android 1.1 SDK to 1.6 SDK and encountered a few issues during the upgrade process.

The first mistake was not reading the upgrade instructions carefully. I misunderstood the statement: “If you currently have version 0.9 or 0.9.1, then you don’t need to uninstall…” to mean 0.9 SDK. The instructions are actually referring to Android Developer Tools (ADT) version 0.9 not the SDK version. After getting a half-baked 0.8 and 0.9 mix of ADT, I uninstalled all of the Android Developer Tools and started over with a fresh install of the 0.9x ADT. And just like months ago, the https URL did not work and I had to use http://dl-ssl.google.com/android/eclipse/ to download the latest tools.
Read more…

Android Coding ,

Leadville 100 2009 Mountain Bike Race Videos by: John Howard

August 25th, 2009

Here’s a collection of Leadville 100 2009 videos in approximate chronological order. This race in Leadville, Colorado is 100 miles long, and all portions are above 9,000 feet. There’s also a 100 mile run for those seeking an something a little more challenging.

Much has been said about certain high profile participants and it reminds me of the you-can’t-surf-here-it’s-our-beach attitude. Thousands of riders participate and there are just as many different ways to experience the race. Some ride slow, some ride like possessed demons. It’s all great.
Read more…

cycling

Curtis’ BBQ Chester, Vermont by: John Howard

August 12th, 2009

Mid-Georgia style BBQ can be found in Chester, Vermont at Curtis’ BBQ restaurant.  Curtis Tuff moved from Georgia to Vermont in 1972 and has operated a BBQ joint in Putney, Vermont since the early 70’s. The location in Chester, VT is operated by Curtis’ daughter, an accomplished griller in her own right.

Yielding to our weakness for ribs we ordered a plate of ‘em, glad we did. The ribs are looooonnnnnggggg! Not sure I’ve ever seen pork ribs this long before. These ribs are presented in their pure state, nothing added except smoke, no trace of rubs or even salt. The flavor was excellent and satisfied our craving for grilled meat.
Read more…

Uncategorized ,

Android ListActivity and Selected State by: John Howard

March 6th, 2009

Here’s a simple desktop dialog that allows the user to select an item from a list and then click an “Action” button to act on the selected item.

desktop list dialog

desktop list dialog

How it works – a user selects an item in the list, that row is highlighted, the user then clicks one of the buttons below the list, the application retrieves the selected index, acts on the selected item and the application continues. Simple right?
Read more…

Android Coding ,

Android dialog Screen Example by: John Howard

February 8th, 2009

This is a basic dialog example that includes a scrolling widget container with an “Ok” and “Cancel” button on the bottom of the screen. This is a general use dialog with a lower case “d” not to be confused with the Android Dialog class. A scrolling area is far from a sophisticated layout design but it is a simple solution for supporting various display sizes. This basic dialog can be used to show user messages, editing of application settings and more. A vertical scrolling layout also future-proofs your applications for distribution on new Android devices with different screen dimensions than what we’re building for today.

scrolling dialog screen

scrolling dialog screen


Read more…

Android Coding , ,