PHPackages                             sh0umik/laravel5-mailjet-5.3-fix - 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. [API Development](/categories/api)
4. /
5. sh0umik/laravel5-mailjet-5.3-fix

ActiveLibrary[API Development](/categories/api)

sh0umik/laravel5-mailjet-5.3-fix
================================

Mailjet driver for Laravel 5 with 5.3 Fix

v1.0.6(9y ago)0781MITPHPPHP &gt;=5.4.0

Since Apr 11Pushed 9y ago1 watchersCompare

[ Source](https://github.com/sh0umik/laravel5-mailjet-5.3-fix)[ Packagist](https://packagist.org/packages/sh0umik/laravel5-mailjet-5.3-fix)[ RSS](/packages/sh0umik-laravel5-mailjet-53-fix/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

Laravel 5 Mailjet Integration
=============================

[](#laravel-5-mailjet-integration)

- **Laravel**: 5
- **Author**: Ramon Ackermann
- **Author Homepage**:

This package extends the Laravel 5 MailService to enable Mailjet integration, based on Mailjet API v3.

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

[](#installation)

Firstly you want to include this package in your composer.json file.

```
"require": {
    "sboo/laravel5-mailjet" : "1.0.*"
}
```

Now you'll want to update or install via composer.

```
composer update

```

Next you open up app/config/app.php and replace the MailServiceProvider with

```
'Sboo\Laravel5MailjetFix\MailjetServiceProvider'
```

**NOTE** It is very important that you replace the default service providers to avoid conflicts. You don't lose any original functionality regarding mail drivers, they are still available.

Configuration is pretty easy: add the following entry to your config/services.php:

```
'mailjet' => [
    'key' => 'APIKEY',
    'secret' => 'APISECRET',
],
```

And replace the values with your respective api key and secret key.

Next, change the mail driver in your config/mail.php or your .env file to 'mailjet', and make sure you have a valid and authorised from-address configured.

That's all and you're good to go. For usage, check the [Laravel 5 mail documentation](http://laravel.com/docs/5.0/mail)

\##API access##

I have also integrated direct access to Mailtjet's API, based on their [example code](https://github.com/mailjet/mailjet-apiv3-php-simple).

To install, append the aliases in config/app.php with

```
'Mailjet'   => 'Sboo\Laravel5MailjetFix\Facades\Mailjet',
```

To use the API in your code, add

```
use Mailjet;
```

### Examples

[](#examples)

*Based on *

#### SendAPI

[](#sendapi)

- A function to send an email :

```
function sendEmail() {
    $params = [
        "method" => "POST",
        "from" => "ms.mailjet@example.com",
        "to" => "mr.mailjet@example.com",
        "subject" => "Hello World!",
        "text" => "Greetings from Mailjet."
    ];

    $result = Mailjet::sendEmail($params);

    if (Mailjet::getResponseCode() == 200)
       echo "success - email sent";
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

- A function to send an email with some attachments (absolute paths on your computer) :

```
function sendEmailWithAttachments() {
    $params = [
        "method" => "POST",
        "from" => "ms.mailjet@example.com",
        "to" => "mr.mailjet@example.com",
        "subject" => "Hello World!",
        "text" => "Greetings from Mailjet.",
        "attachment" => ["@/path/to/first/file.txt", "@/path/to/second/file.txt"]
    ];

    $result = Mailjet::sendEmail($params);

    if (Mailjet::getResponseCode() == 200)
       echo "success - email sent";
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

- A function to send an email with some inline attachments (absolute paths on your computer) :

```
function sendEmailWithInlineAttachments() {

    $params = [
        "method" => "POST",
        "from" => "ms.mailjet@example.com",
        "to" => "mr.mailjet@example.com",
        "subject" => "Hello World!",
        "html" => "Greetings from Mailjet ",
    "inlineattachment" => ["@/path/to/photo1.jpg", "@/path/to/photo2.jpg"]
    ];

    $result = Mailjet::sendEmail($params);

    if (Mailjet::getResponseCode() == 200)
       echo "success - email sent";
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

#### Account Settings

[](#account-settings)

- A function to get your profile information :

```
function viewProfileInfo() {

    $result = Mailjet::myprofile();

    if (Mailjet::getResponseCode() == 200)
       echo "success - got profile information";
    else
       echo "error - ".Mailjet::getResponseCode();
}
```

- A function to update the field `AddressCity` of your profile :

```
function updateProfileInfo() {

    $params = [
        "method" => "PUT",
        "AddressCity" => "New York"
    ];

    $result = Mailjet::myprofile($params);

    if (Mailjet::getResponseCode() == 200)
       echo "success - field AddressCity changed";
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

#### Contact Lists

[](#contact-lists)

- A function to print the list of your contacts :

```
function listContacts()
{

    $result = Mailjet::contact();

    if (Mailjet::getResponseCode() == 200)
       echo "success - listed contacts";
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

- A function to update your contactData resource with ID `$id`, using arrays :

```
function updateContactData($id) {

    $data = [
        ['Name' => 'lastname', 'Value' => 'Jet'],
        ['Name' => 'firstname', 'Value' => 'Mail']
    ];
    $params = [
        'ID' => $id,
        'Data' => $data,
        'method' => 'PUT'
    ];

    $result = Mailjet::contactdata($params);

    if (Mailjet::getResponseCode() == 200)
       echo "success - data changed";
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

- A function to create a list with name `$Lname` :

```
function createList($Lname) {

    $params = [
        "method" => "POST",
        "Name" => $Lname
    ];

    $result = Mailjet::contactslist($params);

    if (Mailjet::getResponseCode() == 201)
       echo "success - created list ".$Lname;
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

- A function to get a list with ID `$listID` :

```
function getList($listID) {

    $params = [
        "method" => "VIEW",
        "ID" => $listID
    ];

    $result = Mailjet::contactslist($params);

    if (Mailjet::getResponseCode() == 200)
       echo "success - got list ".$listID;
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

Note : You can use unique fields of resources instead of IDs, like `"unique" => "test@gmail.com"` in your `params` array for this example

- A function to create a contact with email `$Cemail` :

```
function createContact($Cemail) {

    $params = [
        "method" => "POST",
        "Email" => $Cemail
    ];

    $result = Mailjet::contact($params);

    if (Mailjet::getResponseCode() == 201)
       echo "success - created contact ".$Cname;
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

- A function to add the contact which ID is `$contactID` to the list which ID is `$listID` :

```
function addContactToList($contactID, $listID) {

    $params = [
        "method" => "POST",
        "ContactID" => $contactID,
        "ListID" => $listID,
        "IsActive" => "True"
    ];

    $result = Mailjet::listrecipient($params);

    if (Mailjet::getResponseCode() == 201)
       echo "success - contact ".$contactID." added to the list ".$listID;
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

- A function to delete the list which ID is `$listID` :

```
function deleteList($listID) {

    $params = [
        "method" => "DELETE",
        "ID" => $listID
    ];

    $result = Mailjet::contactslist($params);

    if (Mailjet::getResponseCode() == 204)
       echo "success - deleted list";
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

- A function to get unsubscribed contact(s) from a list with ID `$listID` :

```
function getUnsubscribedContactsFromList($listID) {

	$params = [
		"method" => "GET",
		"ContactsList" => $listID,
		"Unsub" => true
	];

	$result = Mailjet::listrecipient($params);

    if (Mailjet::getResponseCode() == 200)
       echo "success - got unsubscribed contact(s) ";
    else
       echo "error - ".Mailjet::getResponseCode();

	return $result;
}
```

- A function to get a contact with ID `$contactID` :

```
function getContact($contactID) {

    $params = [
        "method" => "VIEW",
        "ID" => $contactID
    ];

    $result = Mailjet::contact($params);

    if (Mailjet::getResponseCode() == 200)
       echo "success - got contact ".$contactID;
    else
       echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

Note : You can use unique fields of resources instead of IDs, like `"unique" => "test@gmail.com"` in your `params` array for this example

#### Newsletters

[](#newsletters)

You can use the `DetailContent` action to manage the content of a newsletter, in Text and Html. It has two properties : `Text-part` and `Html-part`. You can use `GET`, `POST`, `PUT` and `DELETE` both requests on this action :

- `GET` : you get the `Text-part` and `Html-part` properties of a newsletter
- `POST` : update the content of `Text-part` and `Html-part`. If you specify only one, the other will be emptied
- `PUT` : update the content of `Text-part` and `Html-part`. You can specify only one, it will not empty the other one
- `DELETE` : update the content of `Text-part` and `Html-part` and put both to empty.

Example with a `GET` on `DetailContent` :

```
function getNewsletterDetailcontent($newsletter_id) {
    $params = [
        "method" => "GET",
        "ID" => $newsletter_id
    ];

    $result = Mailjet::newsletterDetailContent($params);

    if (Mailjet::getResponseCode() == 200)
        echo "success - got content for the newsletter ". $newsletter_id;
    else
        echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

Use the `schedule` action to send a newsletter later. You just need to perform a `POST` request to schedule a new sending and to fill the `date` property with a Timestamp format in ISO 8601 : You can also `DELETE` a schedule Here is an example :

```
function scheduleNewsletter($newsletter_id) {
    $params = [
        "method" => "POST",
        "ID" => $newsletter_id,
        "date" => "2014-11-25T10:12:59Z"
    );

    $result = Mailjet::newsletterSchedule($params);

    if (Mailjet::getResponseCode() == 201)
        echo "success - schedule done for the newsletter ". $newsletter_id;
    else
        echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

To send a newsletter immediately, you have two possibilities :

- `POST` a new schedule with a Timestamp which value is `NOW`
- use send (only `POST` is supported) For the second case, here is an example :

```
function sendNewsletter($newsletter_id) {

    $params = [
        "method" => "POST",
        "ID" => $newsletter_id
    ];

    $result = Mailjet::newsletterSend($params);

    if (Mailjet::getResponseCode() == 201)
        echo "success - newsletter ". $newsletter_id . " has been sent";
    else
        echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

You can also test a newsletter by sending it to some specified recipients before making the real sending. To do so, you have to perform a `POST` request on a newsletter with action `test` like in the following example :

```
function testNewsletter($newsletter_id) {

    $recipients = [
        ['Email' => 'mailjet@example.org', 'Name' => 'Mailjet']
    ];
    $params = [
        "method" => "POST",
        "ID" => $newsletter_id,
        "Recipients" => $recipients
    ];

    $result = Mailjet::newsletterTest($params);

    if (Mailjet::getResponseCode() == 201)
        echo "success - newsletter ". $newsletter_id . " has been sent";
    else
        echo "error - ".Mailjet::getResponseCode();

    return $result;
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 81.8% of commits — single point of failure

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 ~132 days

Recently: every ~164 days

Total

6

Last Release

3388d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/75d9f866f57d426a8d002ce1d57e532742630f812af2368c8eaab103940506b9?d=identicon)[sh0umik](/maintainers/sh0umik)

---

Top Contributors

[![sboo](https://avatars.githubusercontent.com/u/3823326?v=4)](https://github.com/sboo "sboo (18 commits)")[![sh0umik](https://avatars.githubusercontent.com/u/14281876?v=4)](https://github.com/sh0umik "sh0umik (3 commits)")[![fminov](https://avatars.githubusercontent.com/u/765581?v=4)](https://github.com/fminov "fminov (1 commits)")

---

Tags

apilaravellaravel 5Mailjetv3

### Embed Badge

![Health badge](/badges/sh0umik-laravel5-mailjet-53-fix/health.svg)

```
[![Health](https://phpackages.com/badges/sh0umik-laravel5-mailjet-53-fix/health.svg)](https://phpackages.com/packages/sh0umik-laravel5-mailjet-53-fix)
```

###  Alternatives

[sboo/laravel5-mailjet

Mailjet driver for Laravel 5

154.6k](/packages/sboo-laravel5-mailjet)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[ardakilic/mutlucell

Mutlucell SMS API wrapper for sending sms text messages for Laravel

457.3k](/packages/ardakilic-mutlucell)[dariusiii/tmdb-laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

1821.1k](/packages/dariusiii-tmdb-laravel)[deviddev/billingo-api-v3-wrapper

This is a simple Laravel wrapper for Billingo (billingo.hu) API V3 SwaggerHUB PHP SDK.

2216.3k](/packages/deviddev-billingo-api-v3-wrapper)

PHPackages © 2026

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