Skip to content

Commit

Permalink
Added changelog and updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbull committed May 15, 2017
1 parent a1338f3 commit 012a134
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 33 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# CHANGELOG

## 0.3.0 (2017-xx-xx)
## 0.3.0 (2017-05-15)

- ...
- Added factory methods to create mailer
- Renamed EmailSenderInterface to MailerInterface
- Added setters and getters for Mailers configs

## 0.2.0 (2017-02-06)

Expand Down
75 changes: 44 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
- [Text Body](#email-text-body)
- [HTML Body](#email-html-body)
- [Attachments](#email-attachments)
5. [Exceptions](#exceptions)
6. [Logging](#logging)
7. [License](#license-section)
5. [Factory](#factory)
6. [Exceptions](#exceptions)
7. [Logging](#logging)
8. [License](#license-section)

<a name="requirements"></a>
## Requirements
Expand All @@ -60,7 +61,7 @@ composer require omnimail/omnimail

#### Installation

To use the AmazonSES sender class, you will need to install the `daniel-zahariev/php-aws-ses` library using composer.
To use the AmazonSES mailer class, you will need to install the `daniel-zahariev/php-aws-ses` library using composer.

```
composer require daniel-zahariev/php-aws-ses
Expand All @@ -72,23 +73,23 @@ composer require daniel-zahariev/php-aws-ses
use Omnimail\Email;
use Omnimail\AmazonSES;

$sender = new AmazonSES($accessKey, $secretKey, $region, $verifyPeer, $verifyHost);
$mailer = new AmazonSES($accessKey, $secretKey, $region, $verifyPeer, $verifyHost);

$email = (new Email())
->addTo('example@email.com')
->setFrom('example@email.com')
->setSubject('Hello, world!')
->setTextBody('Hello World! How are you?');

$sender->send($email);
$mailer->send($email);
```

<a name="mailgun"></a>
### Mailgun

#### Installation

To use the Mailgun sender class, you will need to install the `mailgun/mailgun-php` library using composer. You do also
To use the Mailgun mailer class, you will need to install the `mailgun/mailgun-php` library using composer. You do also
need to install a HTTP client that sends messages. You can use any client that provided the virtual package
[php-http/client-implementation](https://packagist.org/providers/php-http/client-implementation)

Expand All @@ -102,23 +103,23 @@ composer require mailgun/mailgun-php php-http/guzzle6-adapter
use Omnimail\Email;
use Omnimail\Mailgun;

$sender = new Mailgun($apiKey, $domain);
$mailer = new Mailgun($apiKey, $domain);

$email = (new Email())
->addTo('example@email.com')
->setFrom('example@email.com')
->setSubject('Hello, world!')
->setTextBody('Hello World! How are you?');

$sender->send($email);
$mailer->send($email);
```

<a name="mailjet"></a>
### Mailjet

#### Installation

To use the Mailjet sender class, you will need to install the `mailjet/mailjet-apiv3-php` library using composer.
To use the Mailjet mailer class, you will need to install the `mailjet/mailjet-apiv3-php` library using composer.

```
composer require mailjet/mailjet-apiv3-php
Expand All @@ -130,23 +131,23 @@ composer require mailjet/mailjet-apiv3-php
use Omnimail\Email;
use Omnimail\Mailjet;

$sender = new Mailjet($apikey, $apisecret);
$mailer = new Mailjet($apikey, $apisecret);

$email = (new Email())
->addTo('example@email.com')
->setFrom('example@email.com')
->setSubject('Hello, world!')
->setTextBody('Hello World! How are you?');

$sender->send($email);
$mailer->send($email);
```

<a name="mandrill"></a>
### Mandrill

#### Installation

To use the Mandrill sender class, you will need to install the `mandrill/mandrill` library using composer.
To use the Mandrill mailer class, you will need to install the `mandrill/mandrill` library using composer.

```
composer require mandrill/mandrill
Expand All @@ -158,23 +159,23 @@ composer require mandrill/mandrill
use Omnimail\Email;
use Omnimail\Mandrill;

$sender = new Mandrill($apiKey);
$mailer = new Mandrill($apiKey);

$email = (new Email())
->addTo('example@email.com')
->setFrom('example@email.com')
->setSubject('Hello, world!')
->setTextBody('Hello World! How are you?');

$sender->send($email);
$mailer->send($email);
```

<a name="postmark"></a>
### Postmark

#### Installation

To use the Postmark sender class, you will need to install the `wildbit/postmark-php` library using composer.
To use the Postmark mailer class, you will need to install the `wildbit/postmark-php` library using composer.

```
composer require wildbit/postmark-php
Expand All @@ -186,23 +187,23 @@ composer require wildbit/postmark-php
use Omnimail\Email;
use Omnimail\Postmark;

$sender = new Postmark($serverApiToken);
$mailer = new Postmark($serverApiToken);

$email = (new Email())
->addTo('example@email.com')
->setFrom('example@email.com')
->setSubject('Hello, world!')
->setTextBody('Hello World! How are you?');

$sender->send($email);
$mailer->send($email);
```

<a name="sendgrid"></a>
### Sendgrid

#### Installation

To use the Sendgrid sender class, you will need to install the `sendgrid/sendgrid` library using composer.
To use the Sendgrid mailer class, you will need to install the `sendgrid/sendgrid` library using composer.

```
composer require sendgrid/sendgrid
Expand All @@ -214,23 +215,23 @@ composer require sendgrid/sendgrid
use Omnimail\Email;
use Omnimail\Sendgrid;

$sender = new Sendgrid($apiKey);
$mailer = new Sendgrid($apiKey);

$email = (new Email())
->addTo('example@email.com')
->setFrom('example@email.com')
->setSubject('Hello, world!')
->setTextBody('Hello World! How are you?');

$sender->send($email);
$mailer->send($email);
```

<a name="sendinblue"></a>
### SendinBlue

#### Installation

To use the SendinBlue sender class, you will need to install the `mailin-api/mailin-api-php` library using composer.
To use the SendinBlue mailer class, you will need to install the `mailin-api/mailin-api-php` library using composer.

```
composer require mailin-api/mailin-api-php
Expand All @@ -242,22 +243,22 @@ composer require mailin-api/mailin-api-php
use Omnimail\Email;
use Omnimail\SendinBlue;

$sender = new SendinBlue($accessKey);
$mailer = new SendinBlue($accessKey);

$email = (new Email())
->addTo('example@email.com')
->setFrom('example@email.com')
->setSubject('Hello, world!')
->setTextBody('Hello World! How are you?');

$sender->send($email);
$mailer->send($email);
```

<a name="email"></a>
## Email

An `Email` object implements the `EmailInterface` inteface. You can create your own `Email` class and send it to any
sender if it implements the `EmailInterface` inteface.
mailer if it implements the `EmailInterface` inteface.

<a name="email-to"></a>
### To
Expand All @@ -273,7 +274,7 @@ $email->addTo('recipent2@email.com', 'Recipient2 Name');
<a name="email-from"></a>
### From

The `From` property of the email is for defining the sender of the email.
The `From` property of the email is for defining the mailer of the email.

```php
$email = new Email();
Expand Down Expand Up @@ -390,6 +391,18 @@ $email->setHtmlBody('<p>Hello!</p><img src="cid:image.png">');
$email->addAttachment($attachment);
```

<a name="factory"></a>
## Factory

Alternatively, you can use the factory method to create a mailer. Consider the following example to create a AmazonSES
mailer:

```php
use Omnimail\Omnimail;

$mailer = Omnimail::create(Omnimail::AMAZONSES, ['accessKey' => $accessKey, 'secretKey' => $secretKey]);
```

<a name="exceptions"></a>
## Exceptions

Expand All @@ -407,7 +420,7 @@ To catch all exception, consider the following.

```php
try {
$sender->send($email);
$mailer->send($email);
} catch (\Omnimail\Exception\Exception $e) {
echo 'Something went wrong: ' . $e->getMessage();
}
Expand All @@ -417,7 +430,7 @@ To catch specific exceptions, consider the following.

```php
try {
$sender->send($email);
$mailer->send($email);
} catch (\Omnimail\Exception\UnauthorizedException $e) {
echo 'Your credentials must be incorrect';
} catch (\Omnimail\Exception\InvalidRequestException $e) {
Expand All @@ -430,7 +443,7 @@ try {
<a name="logging"></a>
## Logging

All sender constructors take a PSR-3 compatible logger.
All mailers constructors take a PSR-3 compatible logger.

Email sent (including the email) are logged at INFO level. Errors (including the email) are reported at the ERROR level.

Expand All @@ -444,8 +457,8 @@ use Omnimail\Mailgun;
$logger = new Logger('name');
$logger->pushHandler(new StreamHandler('path/to/your.log', Logger::INFO));

$sender = new Mailgun($apiKey, $domain, $logger);
$sender->send($email);
$mailer = new Mailgun($apiKey, $domain, $logger);
$mailer->send($email);
```

<a name="license-section"></a>
Expand Down

0 comments on commit 012a134

Please sign in to comment.