Back 1 Comments

Sending Email with Amazon SES SMTP and PHPMailer

We use Amazon SES to send email from some of our clients' web applications.  Recently, we developed a web application for a company who wanted to host the app on their own server.  In this case Amazon SES SMTP provides a security (and possibly performance) advantage over the PHP SDK we were using.  The code below is an example of how to send email using PHPMailer & Amazon SES SMTP.

Download Files (25KB)


//include phpmailer

//SMTP Settings
$mail = new PHPMailer();
$mail->SMTPAuth   = true;
$mail->SMTPSecure = "tls";
$mail->Host       = "";
$mail->Username   = "SMTP-Username";
$mail->Password   = "SMTP-Password";

$mail->SetFrom('', 'Sender Name'); //from (verified email address)
$mail->Subject = "Email Subject"; //subject

$body = "This is a test message.";
$body = eregi_replace("[]",'',$body);

$mail->AddAddress("", "Test Recipient");

if ($mail->Send()) {
    echo "Message sent!"; die;

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


October 30, 2012 6:58am
Hi ,

I have copied the zip file and edited file and added my verified credentials . But it is not working .

Your comment has been posted....