A CodeIgniter library to interact with Amazon Web Services (AWS) Simple Email Service (SES). This library was designed with the standard CodeIgniter email class in mind. As a result, most methods look the same, ensuring a minimal learning curve.
NOTE: this code is still under heavy development and currently provides only the very basics of the AWS SES API (don't you like acronyms?), sending email.
- PHP 5.1+
- CodeIgniter 2.0+
- libcurl with OpenSSL support
- Phil Sturgeon's CodeIgniter cURL library
- A bundle of public root certificates (e.g. http://curl.haxx.se/ca/cacert.pem)
- An Amazon Web Services account
This library is also released as a Spark. If you use this library in any other way, don't copy the autoload.php to your config directory.
This library expects a configuration file to function correctly. A template for this file is provided with the library.
Before you can send your first message, Amazon SES requires that you verify your email address. This is to confirm that you own the email address, and to prevent others from using it.
Request to verify your email address as a sender.
$this->amazon_ses->verify_address('[email protected]');
Check whether a email address is verified as a sender.
$this->amazon_ses->address_is_verified('[email protected]');
Set the "To" address(es) for a message.
$this->amazon_ses->to('[email protected]');
Set the "CC" address(es) (carbon copy) for a message.
$this->amazon_ses->cc('[email protected], [email protected]');
Set the "BCC" address(es) (blind carbon copy) for a message.
$this->amazon_ses->bcc(array('[email protected]', '[email protected]', '[email protected]'));
These three methods expect valid e-mail addresses as a string, array or comma separated list.
###Message
Set the sender address. You can also set this in your config file. The second parameter - the vanity name of the sender - is optional.
$this->amazon_ses->from('[email protected]', 'Email monkey');
Set the subject for a message.
$this->amazon_ses->subject('Open me!');
Set the message to be sent.
$this->amazon_ses->message('<strong>Use HTML</strong>');
Set the alternative message (plain-text) to be sent. When not specified, an alternative message is generated by using PHP's strip_tags() function.
$this->amazon_ses->message_alt('No HTML?!');
Sends the message. Returns true on success. You can pass a boolean as a first parameter to preserve the recipients after the message has been successfully send. This makes it possible to send an additional message without re-specifying the recipients.
$this->amazon_ses->send();
NOTE: All methods above are chainable, which means you can do the following
$this->amazon_ses->to('[email protected]')->subject('Yo!')->message('Sup dawg')->send();
###Misc
Sends the message in debug mode. In debug mode, the send() methods returns the actual API response instead of a boolean. Call this method before calling the send method.
$this->amazon_ses->debug(TRUE);
I am a firm believer of social coding, so if when you find a bug, please fork my code on GitHub and squash it. I will be happy to merge it back in to the code base (and add you to the "Thanks to" section). If you're not too comfortable using Git or messing with the inner workings of this library, please open a new issue.
- Phil Sturgeon, for creating the CodeIgniter cURL library and thus taking care of all the cURL hassle.
- Ben Hartard, for adding the email verification method.
- Stephen Frank, for sorting out SSL conflict issues.
- Fabio Borraccetti, for fixing a bug in the reply-to header.
- Spicer at Cloudmanic Labs, for some small fixes.