Skip to content

Commit 3e9b4dd

Browse files
committed
Made the lib fully compatible with GetSparks.org by providing an autoload.php and the cURL library can now be installed as a Spark or in the normal way. Updated formatting docs too.
1 parent df80cab commit 3e9b4dd

File tree

5 files changed

+44
-42
lines changed

5 files changed

+44
-42
lines changed

.gitignore

+1-29
Original file line numberDiff line numberDiff line change
@@ -1,29 +1 @@
1-
.htaccess
2-
config/doctypes.php
3-
config/profiler.php
4-
config/autoload.php
5-
config/foreign_chars.php
6-
config/routes.php
7-
config/config.php
8-
config/hooks.php
9-
config/smileys.php
10-
config/constants.php
11-
config/index.html
12-
config/user_agents.php
13-
config/database.php
14-
config/mimes.php
15-
config/amazon_ses_real.php
16-
controllers/welcome.php
17-
controllers/index.html
18-
core/
19-
errors/
20-
helpers/
21-
hooks/
22-
index.html
23-
language/
24-
libraries/index.html
25-
models/
26-
third_party/
27-
views/
28-
logs/
29-
libraries/Curl.php
1+
config/amazon_ses_real.php

README.md

+22-9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Requirements
1212
4. Phil Sturgeon's CodeIgniter cURL library (http://github.com/philsturgeon/codeigniter-curl)
1313
5. Amazon Web Services account (http://aws.amazon.com)
1414

15+
Spark
16+
-------------
17+
This library is also released as a Spark (GetSparks.org). If you use this library in any other way, **don't copy the autoload.php to your config directory**.
18+
1519
Documentation
1620
-------------
1721

@@ -20,38 +24,47 @@ This library expects a configuration file to function correctly. A template for
2024

2125
### Recipients
2226

23-
####$this->amazon_ses->to()
2427
Set the "To" address(es) for a message.
2528

26-
####$this->amazon_ses->cc()
29+
$this->amazon_ses->to('to1@example.com');
30+
2731
Set the "CC" address(es) (carbon copy) for a message.
2832

29-
####$this->amazon_ses->bcc()
33+
$this->amazon_ses->cc('cc1@example.com, cc2@example.com');
34+
3035
Set the "BCC" address(es) (blind carbon copy) for a message.
3136

37+
$this->amazon_ses->bcc(array('bcc1@example.com', 'bcc2@example.com', 'bcc3@example.com'));
38+
3239
These three methods expect valid e-mail addresses as a string, array or comma separated list.
3340

3441
###Message
3542

36-
####$this->amazon_ses->subject()
3743
Set the subject for a message.
3844

39-
####$this->amazon_ses->message()
45+
$this->amazon_ses->subject('Open me!');
46+
4047
Set the message to be sent.
4148

42-
####$this->amazon_ses->message_alt()
49+
$this->amazon_ses->message('<strong>Use HTML</strong>');
50+
4351
Set the alternative message (plain-text) to be sent. When not specified, an alternative message is generated by using PHP's strip_tags() function.
4452

45-
####$this->amazon_ses->send()
53+
$this->amazon_ses->message_alt('No HTML?!');
54+
4655
Sends the message. Returns true on success.
4756

57+
$this->amazon_ses->send();
58+
4859
###Misc
4960

50-
####$this->amazon_ses->debug()
5161
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.
62+
63+
$this->amazon_ses->debug();
5264

53-
####$this->amazon_ses->destroy()
5465
Preserves recipient after the message has been successfully send. When you call this method, all recipients will be preserved during the objects life. This makes it possible to sent an additional message without re-specifying the recipients.
66+
67+
$this->amazon_ses->destroy();
5568

5669
Contributing
5770
------------

config/amazon_ses.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Config for the Amazon Simple Email Service library
55
*
6-
* @see /application/libraries/Amazon_ses.php
6+
* @see ../libraries/Amazon_ses.php
77
*/
88

99
// Amazon credentials

config/autoload.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2+
3+
/**
4+
* Autoload for the Amazon Simple Email Service library. Only need when installing through GetSparks.org.
5+
*
6+
* @see ../libraries/Amazon_ses.php
7+
*/
8+
9+
// Add autoload for Sparks
10+
$autoload['libraries'] = array('amazon_ses');

libraries/Amazon_ses.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,15 @@ public function message_alt($message_alt)
173173
*/
174174
public function send($destroy = TRUE)
175175
{
176-
$this->_ci->load->library('curl');
176+
// First try to load the cURL library through Sparks and fall back on the default loader
177+
if (method_exists($this->_ci->load, 'spark'))
178+
{
179+
$this->_ci->load->spark('curl/1.0');
180+
}
181+
else
182+
{
183+
$this->_ci->load->library('curl');
184+
}
177185

178186
// Set the endpoint
179187
$this->_ci->curl->create($this->_endpoint());
@@ -376,6 +384,5 @@ private function _endpoint()
376384
{
377385
return 'https://email.' . $this->region . '.amazonaws.com';
378386
}
379-
380-
387+
381388
}

0 commit comments

Comments
 (0)