PHPackages                             prspace/mailjet - 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. prspace/mailjet

ActiveLibrary[API Development](/categories/api)

prspace/mailjet
===============

Mailjet driver for Laravel

v1.0.1(10y ago)2317MITPHPPHP &gt;=5.4.0

Since Nov 20Pushed 9y agoCompare

[ Source](https://github.com/shawsank/mailjet)[ Packagist](https://packagist.org/packages/prspace/mailjet)[ RSS](/packages/prspace-mailjet/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

Laravel 4 Mailjet Integration
=============================

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

- **Laravel**: 4
- **Author**: Parvez Rahaman
- **Author Homepage**:

This package extends the Laravel 4 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": {
    "prspace/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

```
'Prspace\Mailjet\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 4 mail documentation](http://laravel.com/docs/4.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'   => 'Prspace\Mailjet\Facades\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

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

3829d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/98175853?v=4)[prspace](/maintainers/prspace)[@PRSpace](https://github.com/PRSpace)

---

Top Contributors

[![parvez-rahaman](https://avatars.githubusercontent.com/u/8875411?v=4)](https://github.com/parvez-rahaman "parvez-rahaman (15 commits)")

---

Tags

apilaravelLaravel 4Mailjetv3

### Embed Badge

![Health badge](/badges/prspace-mailjet/health.svg)

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

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[nickurt/laravel-postcodeapi

Universal PostcodeApi for Laravel 11.x/12.x/13.x

97221.2k](/packages/nickurt-laravel-postcodeapi)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[mailjet/mailjet-bundle

Symfony bundle for Mailjet API V3

34395.8k](/packages/mailjet-mailjet-bundle)[sboo/laravel5-mailjet

Mailjet driver for Laravel 5

154.6k](/packages/sboo-laravel5-mailjet)

PHPackages © 2026

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