To get started, you need to first sign-up to the Amazon Simple Email Service.
Once your account is active and you have access to your security keys, you can start using the API. To configure the class with your security keys you have two options:
- Change the $accessKey and $privateKey variables in the class to your security keys appropriately.
- Pass the security keys in an array to the class constructor when instancing the class. Use this way if you have several SES accounts you want to use.
Example using a configuration array:
$ses = new Lionite_AmazonSES( array (
'accessKey' => 'SJVndj58Eghks98Eajgb68',
'privateKey' => 'Jntu4bvf739d/g8bts9h57gaGNvhs85024nfNfjdgh856jd'
Important: before you can send Emails, you must verify the Email addresses you intend to send from and to. Use the
verifyEmail() method described on this page to do that, and click on the link in the verification Email sent to that address.
You can request production access from AWS to skip verifying recipient Email address.
This method is intended for direct use in your scripts.
$recipients parameter can be either an Email string or an array of Emails. Advanced recipient types ('to','cc','bcc') can be specified by using indexed arrays. For example:
$recipients = array(
'to' => array('firstname.lastname@example.org' => 'John Doe'), // 'To' address
'bcc' => array('email@example.com' => 'Jane Joe') // 'Bcc' address
Note: you can use 'email' => 'name' pairs in the array to have named recipients.
$from parameter can be either an Email string or an array of Emails, similar to the
$recipients parameter. Instead of recipient types, you can specify the source of the Email (sent from) and the reply to addresses. Note that the source of the Email must be a verified Email address (see the
verifyEmail() method below).
$from = array(
'source' => array('firstname.lastname@example.org' => 'Site name'), // 'From' address
'reply' => array('email@example.com' => 'Your name') // 'Reply-to' address
$subject parameter is a string containing the subject line.
$body parameter can either be a string containing text body, or an array specifying HTML or mixed body. Use 'text' and 'html' as the array indexes to indicate body type. For example:
$body = array(
'text' => 'This is a text version of the body',
'html' => 'This is an HTML version of the body'
This method is intended for use by abstraction classes that generate Email headers, such as Zend_Mail and SwiftMailer. Direct input of Email headers allows a greater degree of control over advanced Email options. A transport class for Zend_Mail is included in this package.
$to parameter can be either an Email string or an array of Email recipients. Compose the headers appropriately to control body type, recipients types and other advanced options.
$from parameter should contain an Email string and must be a verified Email address (see below).
$headers parameters are strings containing the raw Email body and headers.
Verifying Email addresses
Verifying Email addresses is required to be able to send Emails. You can only send from verified addresses, and if you don't have production access yet you can only send to verified Email addresses as well.
This method accepts an Email address string for verification purposes. A verification Email will be sent to that addresses with a verification link. After the link is pressed, the address will be verified and you can use it to send and receive Emails using the SES service.
This method removes an Email address from the verified Email list.
$email is an Email address string.
This method returns an array of the verified Email addresses.
Account status methods
The Amazon SES provides several methods to get data about the status of your account. A control panel that retrieves and formats this data is included in this package.
This method returns an array of the Email sending quotas - how many Emails were sent in the last 24 hours, how many can be sent every 24 hours and the maximum send rate per second.
This methods returns an array of usage statistics for your SES account. It includes Email sending numbers, rejections, bounces and complaints, grouped by time.