Advertisement
fduran

PHP Amazon mail SES

Sep 23rd, 2013
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. // www.fduran.com
  2. // send mail with Amazon AWS SES without extra library
  3. // needs Pear: apt-get install php-pear
  4. <?php
  5. function mailSES($to, $subject, $body, $from)
  6. {
  7.         include_once('Mail.php');
  8.  
  9.     $headers["From"] = $from;
  10.     $headers["To"] = $to;
  11.     $headers["Subject"] = $subject;
  12.  
  13.     $params["host"] = "ssl://email-smtp.us-east-1.amazonaws.com";
  14.     $params["port"] = "465";
  15.     $params["auth"] = true;
  16.     $params["username"] = "";// NEED USERNAME
  17.     $params["password"] = "";// NEED PASSWORD
  18.  
  19.     try
  20.     {
  21.             $mail_object =& Mail::factory("smtp", $params);
  22.             $mail_res = $mail_object->send($to, $headers, $body);
  23.     }
  24.     catch (Exception $e)
  25.     {
  26.         echo("Error sending mail: " . $e->getMessage() . "\n");
  27.     }
  28.  
  29.     return false;
  30. }
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement