PHPackages                             gavroche/sitesearch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. gavroche/sitesearch

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

gavroche/sitesearch
===================

PHP Library to send email across all platforms using one interface.

0.4.0(4y ago)33017135[6 issues](https://github.com/gabrielbull/php-sitesearch/issues)[1 PRs](https://github.com/gabrielbull/php-sitesearch/pulls)MITPHPPHP &gt;=5.6CI failing

Since Jul 6Pushed 7mo ago14 watchersCompare

[ Source](https://github.com/gabrielbull/php-sitesearch)[ Packagist](https://packagist.org/packages/gavroche/sitesearch)[ RSS](/packages/gavroche-sitesearch/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (16)Versions (18)Used By (0)

[![](https://raw.githubusercontent.com/omnimail/omnimail/development/omnimail-logo.svg)](https://raw.githubusercontent.com/omnimail/omnimail/development/omnimail-logo.svg)

 [![Build Status](https://github.com/omnimail/omnimail/workflows/CI/badge.svg)](https://github.com/omnimail/omnimail/actions?query=workflow%3ACI) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/8137d8430037276c487208486ef78c3ae16e6783c05bbbcadf09abb490b99290/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6f6d6e696d61696c2f6f6d6e696d61696c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/omnimail/omnimail/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/904daa3c5f9e25291aabd8a1a0828418e9001f47ef4a06f413ee7db62ccb9f66/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6f6d6e696d61696c2f6f6d6e696d61696c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/omnimail/omnimail/?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/48981caf07c837d7992ddb858e88c9fdbbedfd53d6a17c92dfa70c753404e0cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6d6e696d61696c2f6f6d6e696d61696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/omnimail/omnimail) [![Join the chat at https://gitter.im/omnimail/omnimail](https://camo.githubusercontent.com/00cf0aeaa884a2a518a29915bf5436374b23858c360d77ac9a86dd6183adb26e/68747470733a2f2f6261646765732e6769747465722e696d2f6f6d6e696d61696c2f6f6d6e696d61696c2e737667)](https://gitter.im/omnimail/omnimail)

Send email across all platforms using one interface.
----------------------------------------------------

[](#send-email-across-all-platforms-using-one-interface)

### Table Of Content

[](#table-of-content)

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Providers](#providers)
    - [AmazonSES](#amazon-ses)
    - [Mailgun](#mailgun)
    - [Mailjet](#mailjet)
    - [Mandrill](#mandrill)
    - [Postmark](#postmark)
    - [Sendgrid](#sendgrid)
    - [SendinBlue](#sendinblue)
    - [SMTP](#smtp)
    - [Gmail](#gmail)
4. [Email](#email)
    - [To](#email-to)
    - [From](#email-from)
    - [CC](#email-cc)
    - [BCC](#email-bcc)
    - [Reply to](#email-reply-to)
    - [Subject](#email-subject)
    - [Text Body](#email-text-body)
    - [HTML Body](#email-html-body)
    - [Attachments](#email-attachments)
5. [Mass Mailings](#mass-mailings)
6. [Factory](#factory)
7. [Exceptions](#exceptions)
8. [Logging](#logging)
9. [License](#license-section)

Requirements
------------

[](#requirements)

This library uses PHP 5.6 and greater version.

Installation
------------

[](#installation)

It is recommended that you install the Omnimail library [through composer](http://getcomposer.org/). To do so, run the Composer command to install the latest stable version of Omnimail library.

```
composer require omnimail/omnimail
```

Providers
---------

[](#providers)

### AmazonSES

[](#amazonses)

#### Installation

[](#installation-1)

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:^0.9.2"

```

#### Usage

[](#usage)

```
use Omnimail\Email;
use Omnimail\AmazonSES;

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

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

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

### Mailgun

[](#mailgun)

#### Installation

[](#installation-2)

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)

```
composer require mailgun/mailgun-php php-http/guzzle6-adapter

```

#### Usage

[](#usage-1)

```
use Omnimail\Email;
use Omnimail\Mailgun;

$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?');

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

### Mailjet

[](#mailjet)

#### Installation

[](#installation-3)

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

```

#### Usage

[](#usage-2)

```
use Omnimail\Email;
use Omnimail\Mailjet;

$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?');

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

### Mandrill

[](#mandrill)

#### Installation

[](#installation-4)

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

```
composer require mandrill/mandrill

```

#### Usage

[](#usage-3)

```
use Omnimail\Email;
use Omnimail\Mandrill;

$mailer = new Mandrill($apiKey);

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

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

### Postmark

[](#postmark)

#### Installation

[](#installation-5)

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

```
composer require wildbit/postmark-php

```

#### Usage

[](#usage-4)

```
use Omnimail\Email;
use Omnimail\Postmark;

$mailer = new Postmark($serverApiToken);

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

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

### Sendgrid

[](#sendgrid)

#### Installation

[](#installation-6)

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

```
composer require sendgrid/sendgrid

```

#### Usage

[](#usage-5)

```
use Omnimail\Email;
use Omnimail\Sendgrid;

$mailer = new Sendgrid($apiKey);

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

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

### SendinBlue

[](#sendinblue)

#### Installation

[](#installation-7)

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

```

#### Usage

[](#usage-6)

```
use Omnimail\Email;
use Omnimail\SendinBlue;

$mailer = new SendinBlue($accessKey);

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

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

### SMTP

[](#smtp)

#### Installation

[](#installation-8)

To use the SMTP mailer class, you will need to install the `phpmailer/phpmailer` library using composer.

```
composer require phpmailer/phpmailer

```

#### Usage

[](#usage-7)

```
use Omnimail\Email;
use ShahariaAzam\SMTPMailer\SMTPMailer;

$mailer = new SMTPMailer("SMTP HOSTNAME", "SMTP USERNAME", "SMTP PASSWORD");

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

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

### Gmail

[](#gmail)

#### Installation

[](#installation-9)

To use the Gmail mailer class, you will need to install the `phpmailer/phpmailer` library using composer.

```
composer require phpmailer/phpmailer

```

#### Usage

[](#usage-8)

```
use Omnimail\Email;
use Omnimail\Gmail;

$mailer = new Gmail("you@gmail.com", "password", []);

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

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

Email
-----

[](#email)

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

### To

[](#to)

The `To` property of the email is for defining the recipients of the email. You can set multiple recipients.

```
$email = new Email();
$email->addTo('recipent1@email.com', 'Recipient1 Name');
$email->addTo('recipent2@email.com', 'Recipient2 Name');
```

### From

[](#from)

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

```
$email = new Email();
$email->setFrom('sender@email.com', 'Sender Name');
```

### CC

[](#cc)

Like the `To` property, the `CC` property can have multiple recipients.

```
$email = new Email();
$email->addCc('recipent1@email.com', 'Recipient1 Name');
$email->addCc('recipent2@email.com', 'Recipient2 Name');
```

### BCC

[](#bcc)

Like the `To` property, the `BCC` property can have multiple recipients.

```
$email = new Email();
$email->addBcc('recipent1@email.com', 'Recipient1 Name');
$email->addBcc('recipent2@email.com', 'Recipient2 Name');
```

### Reply To

[](#reply-to)

The `Reply To` property of the email is for defining the email that should receive responses.

```
$email = new Email();
$email->setReplyTo('sender@email.com', 'Sender Name');
```

### Subject

[](#subject)

The `Subject` property of the email is for defining the subject of the email.

```
$email = new Email();
$email->setSubject('Hello, World!');
```

### Text Body

[](#text-body)

The `Text Body` property of the email is for defining the text body of the email.

```
$email = new Email();
$email->setTextBody('This is plain text.');
```

### HTML Body

[](#html-body)

The `HTML Body` property of the email is for defining the HTML body of the email.

```
$email = new Email();
$email->setHtmlBody('Hi!This is HTML!');
```

### Attachments

[](#attachments)

The `Attachments` property of the email is for joining attachments to the email.

#### Example using string as content

[](#example-using-string-as-content)

```
use Omnimail\Email;
use Omnimail\Attachment;

$attachment = new Attachment();
$attachment->setName('my_file.txt');
$attachment->setMimeType('text/plain');
$attachment->setContent('This is plain text');

$email = new Email();
$email->addAttachment($attachment);
```

#### Example using file path as content

[](#example-using-file-path-as-content)

```
use Omnimail\Email;
use Omnimail\Attachment;

$attachment = new Attachment();
$attachment->setMimeType('text/plain');
$attachment->setPath(__DIR__ . '/my_file.txt');

$email = new Email();
$email->addAttachment($attachment);
```

### Inline attachments

[](#inline-attachments)

```
use Omnimail\Email;
use Omnimail\Attachment;

$attachment = new Attachment();
$attachment->setPath(__DIR__ . '/image.png');
$attachment->setContentId('image.png');

$email = new Email();
$email->setHtmlBody('Hello!');
$email->addAttachment($attachment);
```

Factory
-------

[](#factory)

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

```
use Omnimail\Omnimail;

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

Mass Mailings
-------------

[](#mass-mailings)

The mass mailing component is for interacting with mass mailing providers. Currently the code focusses on data retrieval, but in future it should also define creating and sending mass mailings.

There are 2 functions currently described for the Mass mailings interface `getMailings` and `getRecipients`.

**getMailings**

```
    $mailer = Omnimail::create('Silverpop', array('credentials' => new Credentials(array('username' => $userName...)))->getMailings();
    $mailer->setStartTimeStamp(strtotime('7 days ago'));
    $mailer->setEndTimeStamp(strtotime('now'));
    // Instead of using set methods a Credentials object can be passed in ie.
    // Omnimail::create('Silverpop', array('credentials' => new Credentials(array('username' => $userName...)));
    // The advantage of using the Credentials object is that the object will not disclose
    // the credentials when var_dump or similar is called, helping to make the code
    // more secure.

    $mailings = $mailer->getResponse();
    for ($i = 0; $i < 15; $i++) {
      if (!$mailings->isCompleted()) {
        sleep(15);
      }
      else {
        foreach (\Omnimail\Common\Responses\BaseResponse $mailings as \Omnimail\Common\Responses\Mailing $mailing) {

           $detail => array(
             'subject' => $mailing→getSubject(),
             'external_identifier' => $mailing->getMailingIdentifier(),
             'name' => $mailing->getName(),
             'scheduled_date' => $mailing->getScheduledDate(),
             'start_date' => $mailing->getSendStartDate(),
             'number_sent' => $mailing->getNumberSent(),
             'body_html' => $mailing->getHtmlBody(),
             'body_text' => $mailing→getTextBody(),
             // Note that in the case of Silverpop these statistics are not retrieved by the
             // same api call. This is invisible to the calling function, and unless
             // stats are requested they are not retrieved.
             'number_bounced' => $mailing->getNumberBounces(),
             'number_opened_total' => $mailing->getNumberOpens(),
             'number_opened_unique' => $mailing->getNumberUniqueOpens(),
             'number_unsubscribed' => $mailing->getNumberUnsubscribes(),
             'number_suppressed' => $mailing->getNumberSuppressedByProvider(),
             // 'forwarded'
             'number_blocked' => $mailing->getNumberBlocked(),
             // 'clicked_total' => $stats['NumGrossClick'],
             'number_abuse_complaints' => $mailing->getNumberAbuseReports(),
            );
          }
      }
    }
```

**getMailings**

```
    $mailer = Omnimail::create('Silverpop')->getRecipients();
    $mailer->setUserName($userName);
    $mailer->setPassword($password);
    $mailer->setStartTimeStamp(strtotime('7 days ago'));
    $mailer->setEndTimeStamp(strtotime('now'));
    $mailer->setMailingIdentifier(123);

    $recipients = $mailer->getResponse();
    if (!$recipients->isCompleted()) {
      // sleep or exit & retry later.
    }

    foreach (\Omnimail\Responses\RecipientsResponse $recipients as \Omnimail\Responses\Recipient $$recipient) {

     $detail => array(
       'external_identifier' => $mailing->getMailingIdentifier(),
       'email' =>  $mailing->getEmail(),
       'provider_contact_id' => $mailing->getContactIdentifier(),
       'contact_id' => $mailing->GetContactReference(),
        // Const ACTION_SENT = ‘Sent’, ACTION_OPENED = ‘Open’, ...
       'action' => $mailing->getRecipientAction(),
       'timestamp' => getRecipientActionTimestamp(),
     );
```

Exceptions
----------

[](#exceptions)

Failures to send emails will throw exceptions.

**Exceptions**

- Omnimail\\Exception\\Exception
- Omnimail\\Exception\\EmailDeliveryException
- Omnimail\\Exception\\InvalidRequestException
- Omnimail\\Exception\\UnauthorizedException
- Omnimail\\Exception\\MailerNotFoundException

To catch all exception, consider the following.

```
try {
    $mailer->send($email);
} catch (\Omnimail\Exception\Exception $e) {
    echo 'Something went wrong: ' . $e->getMessage();
}
```

To catch specific exceptions, consider the following.

```
try {
    $mailer->send($email);
} catch (\Omnimail\Exception\UnauthorizedException $e) {
    echo 'Your credentials must be incorrect';
} catch (\Omnimail\Exception\InvalidRequestException $e) {
    echo 'The request is badly formatted, check that all required fields are filled.';
} catch (\Omnimail\Exception\EmailDeliveryException $e) {
    echo 'The email did not go out.';
}
```

Logging
-------

[](#logging)

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.

### Example using Monolog

[](#example-using-monolog)

```
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Omnimail\Mailgun;

$logger = new Logger('name');
$logger->pushHandler(new StreamHandler('path/to/your.log', Logger::INFO));

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

License
-------

[](#license)

Omnimail is licensed under [The MIT License (MIT)](LICENSE).

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance44

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~139 days

Recently: every ~154 days

Total

14

Last Release

1785d ago

PHP version history (2 changes)0.1.0PHP ^5.5 || ^7.0

0.4.0PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/a47f4f3ae12f240f28606174b2a5c9da031f94300f5aa6eb27f4b0977d9cfca4?d=identicon)[gavroche](/maintainers/gavroche)

---

Top Contributors

[![gabrielbull](https://avatars.githubusercontent.com/u/671923?v=4)](https://github.com/gabrielbull "gabrielbull (56 commits)")[![shahariaazam](https://avatars.githubusercontent.com/u/1095008?v=4)](https://github.com/shahariaazam "shahariaazam (31 commits)")[![eileenmcnaughton](https://avatars.githubusercontent.com/u/336308?v=4)](https://github.com/eileenmcnaughton "eileenmcnaughton (15 commits)")[![stevecoug](https://avatars.githubusercontent.com/u/432808?v=4)](https://github.com/stevecoug "stevecoug (13 commits)")[![daarond](https://avatars.githubusercontent.com/u/572928?v=4)](https://github.com/daarond "daarond (5 commits)")[![bretto36](https://avatars.githubusercontent.com/u/6217994?v=4)](https://github.com/bretto36 "bretto36 (2 commits)")[![suhaboncukcu](https://avatars.githubusercontent.com/u/2428828?v=4)](https://github.com/suhaboncukcu "suhaboncukcu (1 commits)")[![Nenillo](https://avatars.githubusercontent.com/u/355259?v=4)](https://github.com/Nenillo "Nenillo (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")

---

Tags

amazonsesemailemail-sendermailgunmailjetmandrillphpphp7postmarksendgridsendinbluemailemailsendgridmailgunmandrillMailjetdeliverypostmarksendinblueAmazon SES

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/gavroche-sitesearch/health.svg)

```
[![Health](https://phpackages.com/badges/gavroche-sitesearch/health.svg)](https://phpackages.com/packages/gavroche-sitesearch)
```

###  Alternatives

[omnimail/omnimail

PHP Library to send email across all platforms using one interface.

32934.3k](/packages/omnimail-omnimail)[slm/mail

Integration of various email service providers in the Laminas\\Mail

108732.4k1](/packages/slm-mail)[zbateson/mail-mime-parser

MIME email message parser

53949.2M79](/packages/zbateson-mail-mime-parser)[stampie/stampie

Stampie is a simple API Wrapper for different email providers such as Postmark, SendGrid, Mailgun, Mandrill.

294254.8k4](/packages/stampie-stampie)[coconutcraig/laravel-postmark

Laravel package for sending mail via the Postmark API

2152.9M1](/packages/coconutcraig-laravel-postmark)[boundstate/yii2-mailgun

Mailgun integration for the Yii framework

28160.6k](/packages/boundstate-yii2-mailgun)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
