Sending Email with Amazon SES SMTP and PHPMailer


You can use Amazon SES to send email from your web applications. 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.

//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(‘[email protected]’, ‘Sender Name’); //from (verified email address)
$mail->Subject = “Email Subject”; //subject

$body = “This is a test message.”;

$mail->AddAddress(“[email protected]”, “Test Recipient”);

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

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



Leave a Reply

Your email address will not be published. Required fields are marked *