Postmark API Wrapper for CodeIgniterJR Tashjian
This project is no longer maintained.
I've been using Postmark and it's API for quite a while. If you're still sending out emails through PHP's mail() function, you need to check out Postmark! With Postmark you can off-load those transactional emails and not have to worry about it yourself.
While there is a Postmark API Wrapper for CodeIgniter already, I felt it was unnecessary to create an entirely different Email class just to send off API requests to Postmark. Instead, this library extends the Core CI_Email class, retaining the small footprint philosophy of CodeIgniter.
- Download the library from Github.
There is only one setting you need to update in the config file (
application/config/postmark.php) and that is your Postmark API key. You can find your API key from the Server Details -> Credentials page in your Postmark Account.
$config['postmark_api_key'] = "YOUR_API_KEY_HERE";
Loading the Library
To use the library, you will need to load it along with the Core CI_Email library (because we extend it).
$this->load->library( 'email' ); $this->load->library( 'postmark' );
$this->load->library( array( 'email', 'postmark' ) );
Just make sure to load the Core CI_Email (email) class first.
Sending an Email
The great thing about extending the Core CI_Email class is the ability to not have to change the way you use the class! The only difference is that you will be calling functions as
$this->postmark->function_name() instead of
$this->load->library( 'email' ); $this->load->library( 'postmark' ); $this->postmark->from( 'your_example.com', 'Your Name' ); $this->postmark->to( 'email@example.com' ); $this->postmark->cc( 'firstname.lastname@example.org' ); $this->postmark->bcc( 'email@example.com' ); $this->postmark->subject( 'Email Test' ); $this->postmark->message( 'Testing the email class.' ); $this->postmark->send();
$this->postmark->from(), you will have to use your Postmark API Sender Signature located on the Signatures page in your Postmark Account.
April 22nd, 2011 - Initial Release