Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fduran/11400633 to your computer and use it in GitHub Desktop.
Save fduran/11400633 to your computer and use it in GitHub Desktop.
// www.fduran.com
// send mail with Amazon AWS SES without extra library
// needs Pear: apt-get install php-pear
<?php
function mailSES($to, $subject, $body, $from)
{
include_once('Mail.php');
$headers["From"] = $from;
$headers["To"] = $to;
$headers["Subject"] = $subject;
$params["host"] = "ssl://email-smtp.us-east-1.amazonaws.com";
$params["port"] = "465";
$params["auth"] = true;
$params["username"] = "";// NEED USERNAME
$params["password"] = "";// NEED PASSWORD
try
{
$mail_object =& Mail::factory("smtp", $params);
$mail_res = $mail_object->send($to, $headers, $body);
}
catch (Exception $e)
{
echo("Error sending mail: " . $e->getMessage() . "\n");
}
return false;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment