Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed May 28, 2013
2 parents 0abbd08 + 3e69d55 commit e762ab5
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 1.0.0 RC3

- Add exceptions support for Amazon SES.
- Now allow the new "metadata" option in Mandrill message
- Http adapter can now be configured more easily

## 1.0.0 RC2
- Licensing of `composer.json` and all files inside SlmMail
- Addition of a CHANGELOG document
Expand Down
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SlmMail

[![Build Status](https://travis-ci.org/juriansluiman/SlmMail.png?branch=amazon-ses-exceptions)](https://travis-ci.org/juriansluiman/SlmMail)

Version 1.0.0 Created by Jurian Sluiman and Michaël Gallego
Version 1.0.0-rc3 Created by Jurian Sluiman and Michaël Gallego

Introduction
------------
Expand Down Expand Up @@ -41,12 +41,15 @@ file called `composer.json` and save it in the root of your project:

```
{
"minimum-stability": "rc",
"require": {
"slm/mail": ">=1.*"
"slm/mail": "1.*"
}
}
```

> minimum-stability attribute is required as we have not reached final version yet.
Then execute the following commands in a CLI:

```
Expand Down Expand Up @@ -97,6 +100,32 @@ $message->setBody($body);

> For accessibility purposes, you should *always* provide both a text and HTML version of your mails.
### How to configure HttpClient with http_options and http_adapter

By defaut the adapter is Zend\Http\Client\Adapter\Socket but you can override it with other adapter like this in your slm_mail.*.local.php

```php
'slm_mail' => array(
// Here your email service provider options

'http_adapter' => 'Zend\Http\Client\Adapter\Proxy' // for example
)
```

If you want to change some options of your adapter please refer to you adapter class in var $config [here](https://github.com/zendframework/zf2/tree/master/library/Zend/Http/Client/Adapter) and override these in your slm_mail.*.local.php like this :

```php
'slm_mail' => array(
// Here your email service provider options

// example for Socket adapter
'http_options' => array(
'sslverifypeer' => false,
'persistent' => true,
),
)
```

### Pricing comparison

Here is a table of prices for each service providers (if they are outdated please create an issue). Of course, you
Expand Down
4 changes: 4 additions & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@
'SlmMail\Http\Client' => 'SlmMail\Factory\HttpClientFactory',
),
),

'slm_mail' => array(
'http_adapter' => 'Zend\Http\Client\Adapter\Socket',
),
);
11 changes: 4 additions & 7 deletions src/SlmMail/Factory/HttpClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,12 @@ public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');

if (!isset($config['slm_mail']['http_adapter'])
|| !isset($config['slm_mail']['http_options'])
) {
return new HttpClient();
}

$client = new HttpClient();
$client->setAdapter($config['slm_mail']['http_adapter']);
$client->getAdapter()->setOptions($config['slm_mail']['http_options']);

if (isset($config['slm_mail']['http_options'])) {
$client->getAdapter()->setOptions($config['slm_mail']['http_options']);
}

return $client;
}
Expand Down
19 changes: 10 additions & 9 deletions src/SlmMail/Mail/Message/Mandrill.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,20 @@ class Mandrill extends Message
* @var array
*/
protected $validOptions = array(
'important',
'track_opens',
'track_clicks',
'auto_text',
'auto_html',
'auto_text',
'google_analytics_campaign',
'google_analytics_domains',
'important',
'inline_css',
'url_strip_qs',
'merge',
'metadata',
'preserve_recipients',
'tracking_domain',
'signing_domain',
'merge',
'google_analytics_domains',
'google_analytics_campaign'
'track_clicks',
'track_opens',
'tracking_domain',
'url_strip_qs'
);

/**
Expand Down
87 changes: 87 additions & 0 deletions tests/SlmMailTest/Http/ClientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/**
* Copyright (c) 2012-2013 Jurian Sluiman.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the names of the copyright holders nor the names of the
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @author Jurian Sluiman <[email protected]>
* @copyright 2012-2013 Jurian Sluiman.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @link http://juriansluiman.nl
*/

namespace SlmMailTest\Http;

use PHPUnit_Framework_TestCase;
use SlmMailTest\Util\ServiceManagerFactory;

class ClientTest extends PHPUnit_Framework_TestCase
{
public function testAssertSocketAdapterIsUsedByDefault()
{
/** @var \Zend\Http\Client $client */
$client = ServiceManagerFactory::getServiceManager()->get('SlmMail\Http\Client');
$this->assertInstanceOf('Zend\Http\Client\Adapter\Socket', $client->getAdapter());
}

public function testAssertCanChangeAdapter()
{
$serviceManager = ServiceManagerFactory::getServiceManager();
$serviceManager->setAllowOverride(true);

$config = $serviceManager->get('Config');
$config['slm_mail']['http_adapter'] = 'Zend\Http\Client\Adapter\Test';

$serviceManager->setService('Config', $config);

/** @var \Zend\Http\Client $client */
$client = $serviceManager->get('SlmMail\Http\Client');
$this->assertInstanceOf('Zend\Http\Client\Adapter\Test', $client->getAdapter());
}

public function testCanSetOptionsForHttpAdapter()
{
$serviceManager = ServiceManagerFactory::getServiceManager();
$serviceManager->setAllowOverride(true);

$config = $serviceManager->get('Config');
$config['slm_mail']['http_options'] = array(
'sslverifypeer' => false
);

$serviceManager->setService('Config', $config);

/** @var \Zend\Http\Client $client */
$client = $serviceManager->get('SlmMail\Http\Client');
$config = $client->getAdapter()->getConfig();
$this->assertFalse($config['sslverifypeer']);
}
}

0 comments on commit e762ab5

Please sign in to comment.