Archive

Archive for the ‘php’ Category

Sending Email with PHP, PHPMailer and Amazon SES

January 21st, 2012 No comments

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

Categories: php Tags:

Installing Nginx with php-fpm on Ubuntu 10.04 and 11.10

January 9th, 2011 No comments

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…

Categories: linux, php, nginx Tags: , ,