PHPackages                             quanti/mailq-connector - 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. quanti/mailq-connector

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

quanti/mailq-connector
======================

Library used for communication with MailQ REST API

v0.9.3(4y ago)018.8k↓33.3%5[1 PRs](https://github.com/QuantiCZ/MailQ-PHP-Library/pulls)MITPHPPHP &gt;=7.2.0

Since Sep 15Pushed 4y ago3 watchersCompare

[ Source](https://github.com/QuantiCZ/MailQ-PHP-Library)[ Packagist](https://packagist.org/packages/quanti/mailq-connector)[ Docs](http://mailq.cz)[ RSS](/packages/quanti-mailq-connector/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (3)Versions (29)Used By (0)

MailQ PHP library
=================

[](#mailq-php-library)

Instalation
-----------

[](#instalation)

### Composer

[](#composer)

```
composer require quanti/mailq-connector

```

### Using in Nette

[](#using-in-nette)

Add this section to your config. You should use different URL and API key for development and production environment.

Usage
-----

[](#usage)

There is MailQ object which is facade to whole MailQ REST API. Most common use case is only one company in MailQ per customer. You need to instantiate MailQ object with company ID. Because there are also customers with multiple companies there is MailQFactory which creates MailQ for specific company.

```
$apiKey = "6e2211bf472a9478f03420fb5897e324c57d05fc27bc0e871083275e98eec344";
$apiUrl = "http://mailq-test.quanti.cz/api/v2";
$mailqFactory = new MailQFactory($apiUrl);
$companyId = 1;
$mailq = $mailqFactory->createMailQ($companyId, $apiKey);
```

### Running sandbox with Docker

[](#running-sandbox-with-docker)

Sandbox is minimum application for playing around with PHP MailQ library.

#### Windows

[](#windows)

- Run `docker run --rm -it -v %cd%:/app composer install` to install PHP dependencies
- Run `docker run --rm -it -v %cd%:/app php:cli php /app/sandbox/sandbox.php  `

#### Unix

[](#unix)

- Run `docker run --rm -it -v $(pwd):/app composer install` to install PHP dependencies
- Run `docker run --rm -it -v $(pwd):/app php:cli php /app/sandbox/sandbox.php  `

Where API key is your private company key used for authentication and company ID is integer number used for identication company.

### [Campaign resource](http://docs.newmailing.apiary.io/#campaigns)

[](#campaign-resource)

#### Get all campaigns

[](#get-all-campaigns)

```
$campaigns = $mailq->getCampaigns();
```

#### Get single campaign

[](#get-single-campaign)

```
$campaignId = 1;
$campaigns = $mailq->getCampaign();
```

### [Company resource](http://docs.newmailing.apiary.io/#companies)

[](#company-resource)

#### Get company

[](#get-company)

```
$company = $mailq->getCompany();
```

#### Regenerate API key

[](#regenerate-api-key)

Use this with caution! After regenerating API key application will throw errors because you have already create connection

```
$apiKey = $mailq->regenerateApiKey();
```

### [Log message resource](http://docs.newmailing.apiary.io/#logmessages)

[](#log-message-resource)

#### Get all log messages

[](#get-all-log-messages)

```
$logMessagesEntity = $mailq->getLogMessages();
```

#### Get single log message

[](#get-single-log-message)

```
$logMessageId = 1;
$logMessageEntity = $mailq->getLogMessage($logMessageId);
```

### [Newsletter resource](http://docs.newmailing.apiary.io/#newsletters)

[](#newsletter-resource)

#### Create newsletter

[](#create-newsletter)

```
$data = [
    "name" => "Awesome newsletter",
    "campaign"=> "Spring 2016",
    "subject" => "Buy our new product",
    "senderEmail" => "newsletter@example.org",
    "sendAs" => "Awesome Company",
    "from" => "2018-07-01T00:00:00+00:00",
    "to" => "2018-07-02T00:00:00+00:00",
    "text"=> "TmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciw=",
    "automaticTime"=> false,
    "recipientsListId"=>1,
    "templateUrl" => "http://example.org/newsletter.html",
    "unsubscribeTemplateUrl" => "http://example.org/unsubscribe.html"
];
$newsletter = new \MailQ\Entities\v2\NewsletterEntity($data);
$mailq->createNewsletter($newsletter);
$newsletterId = $newsletter->getId();
```

#### Update newsletter

[](#update-newsletter)

```
$data = [
    "id" => 1,
    "name" => "Awesome newsletter",
    "campaign" => "Spring 2016",
    "subject" => "Buy our new product",
    "senderEmail" => "newsletter@example.org",
    "sendAs" => "Awesome Company",
    "from" => "2018-07-01T00:00:00+00:00",
    "to" => "2018-07-02T00:00:00+00:00",
    "text" => "TmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciw=",
    "automaticTime" => false,
    "recipientsListId" => 1,
    "templateUrl" => "http://example.org/newsletter.html",
    "ampTemplateUrl" => "http://example.org/ampNewsletter.html",
    "unsubscribeTemplateUrl" => "http://example.org/unsubscribe.html"
];
$newsletter = new \MailQ\Entities\v2\NewsletterEntity($data);
$mailq->updateNewsletter($newsletter);
$newsletterId = $newsletter->getId();
```

#### Update newsletter in ready state

[](#update-newsletter-in-ready-state)

```
$data = [
    "id" => 1,
    "name" => "Awesome newsletter",
    "campaign" => "Spring 2016",
    "subject" => "Buy our new product",
    "senderEmail" => "newsletter@example.org",
    "replyToEmail" : "newsletter@example.org",
    "sendAs" => "Awesome Company",
    "text" => "TmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciwgbmV3c2xldHRlciw=",
    "automaticTime" => false,
    "templateUrl" => "http://example.org/newsletter.html",
    "ampTemplateUrl" => "http://example.org/ampNewsletter.html",
    "unsubscribeTemplateUrl" => "http://example.org/unsubscribe.html"
];
$newsletter = new \MailQ\Entities\v2\NewsletterEntity($data);
$mailq->updateNewsletter($newsletter);
$newsletterId = $newsletter->getId();
```

#### Get all newsletters

[](#get-all-newsletters)

```
$newsletters = $mailq->getNewsletters();
```

#### Get newsletter

[](#get-newsletter)

```
$newsletterId = 1;
$newsletter = $mailq->getNewsletter($newsletterId);
```

#### Send test e-mail

[](#send-test-e-mail)

```
$newsletterId = 1;
$email = "test@example.org";
$mailq->sendTestEmail($email,$newsletterId);
```

#### Start preparation of newsletter

[](#start-preparation-of-newsletter)

```
$newsletterId = 1;
$mailq->startNewsletter($newsletterId);
```

#### Stop preparation of newsletter

[](#stop-preparation-of-newsletter)

```
$newsletterId = 1;
$mailq->stopNewsletter($newsletterId);
```

### [Notification resource](http://docs.newmailing.apiary.io/#notifications)

[](#notification-resource)

#### Create notification

[](#create-notification)

```
$data = [
    "name" => "First Notification",
    "code" => "N1",
    "subject" => "{{orderNumber}} order is ready",
    "sendAs" => "Awesome Company",
    "text" => "QWx0ZXJuYXRpdmUgYmFzZTY0IGVtYWlsIHRleHQ=",
    "template" => "QWx0ZXJuYXRpdmUgYmFzZTY0IGVtYWlsIHRleHQ=",
    "ampTemplate" => "QWx0ZXJuYXRpdmUgYmFzZTY0IGVtYWlsIHRleHQ=",
    "appliedSenderEmail" => "notification@example.org"
];
$notification = new \MailQ\Entities\v2\NotificationEntity($data);
$mailq->createNotification($notification);
$notificationId = $notification->getId();
```

#### Update notification

[](#update-notification)

```
$data = [
    "id" => 1,
    "name" => "First Notification",
    "code" => "N1",
    "subject" => "{{orderNumber}} order is ready",
    "sendAs" => "Awesome Company",
    "text" => "QWx0ZXJuYXRpdmUgYmFzZTY0IGVtYWlsIHRleHQ=",
    "template" => "QWx0ZXJuYXRpdmUgYmFzZTY0IGVtYWlsIHRleHQ=",
    "ampTemplate" => "QWx0ZXJuYXRpdmUgYmFzZTY0IGVtYWlsIHRleHQ=",
    "appliedSenderEmail" => "notification@example.org"
];
$notification = new \MailQ\Entities\v2\NotificationEntity($data);
$mailq->updateNotification($notification);
```

#### Get all notifications

[](#get-all-notifications)

```
$notifications = $mailq->getNotifications();
```

#### Delete notification

[](#delete-notification)

```
$notificationId = 1;
$mailq->deleteNotification($notificationId);
```

#### Send notification e-mail

[](#send-notification-e-mail)

In data section are all values which will be used in notification. Keys of associative array are variable names and values are values.

```
$data = [
    "recipientEmail" => "recipient@example.org",
    "data" => [
        "key1" => "value1",
        "key2" => "value2"
    ],
    "attachments" => [
        [
            "displayName" =>  "Priloha 1",
            "link" => "http://example.org/test.txt",
            "source" => "dGVzdHM=",
            "mimeType" => "text/plain"
        ],
        [
            "displayName" => "Priloha 2",
            "link" => "http://example.org/image.png",
            "source" => "R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
            "mimeType" => "image/png"
        ]
    ]
];
$notificationId = 1;
$notificationData = new \MailQ\Entities\v2\NotificationDataEntity($data);
$mailq->sendNotificationEmail($notificationData,$notificationId);
$notificationDataId = $notificationData->getId();
```

#### Get notification e-mail

[](#get-notification-e-mail)

```
$notificationId = 1;
$notificationDataId = 2;
$notificationData = $mailq->getNotificationData($notificationId,$notificationDataId);
```

#### Get all notification e-mails

[](#get-all-notification-e-mails)

```
$notificationId = 1;
$email = "recipiet@example.org";
$notificationsData = $mailq->getNotificationsData($notificationId,$email);
```

### [Recipients list resource](http://docs.newmailing.apiary.io/#recipientslist)

[](#recipients-list-resource)

#### Create recipients list

[](#create-recipients-list)

```
$mailq = $mailqFactory->createMailQ($companyId);
$data = [
    "name" => "All clients",
    "description" => "All clients of our awesome company",
    "variables" => ["salutation","gender"],
    "formVisible" => true
];
$recipientsList = new \MailQ\Entities\v2\RecipientsListEntity($data);
$mailq->createRecipientsList($recipientsList);
$recipientsListId = $recipientsList->getId();
```

#### Delete recipients list

[](#delete-recipients-list)

```
$recipientsListId = 1;
$mailq->deleteRecipientsList($recipientListId);
```

#### Get recipients list

[](#get-recipients-list)

```
$recipientsListId = 1;
$recipientsList = $mailq->getRecipientsList($recipientListId);
```

#### Get recipients lists

[](#get-recipients-lists)

You can specify e-mail and API returns only recipients list which contains this e-mail

```
$email = "recipient@example.org";
$recipientsLists = $mailq->getRecipientsLists($email);
```

#### Get all recipients

[](#get-all-recipients)

```
$recipientsListId = 1;
$recipients = $mailq->getRecipients($recipientsListId);
```

#### Add multiple recipients at once

[](#add-multiple-recipients-at-once)

```
$data = [
	"recipients" => [
		[
			"email" => "recipient@example.org",
	        "data" => [
	            "key1" => "value1",
	            "key2" => "value2"
	        ]
		]
	]
];
$recipients = new \MailQ\Entities\v2\RecipientsEntity($data);
$recipientsListId = 1;
$validate = false;
$mailq->addRecipients($recipients,$recipientsListId,$validate);
```

#### Update or create recipient

[](#update-or-create-recipient)

```
$data = [
	"email" => "recipient@example.org",
    "data" => [
        "key1" => "value1",
        "key2" => "value2"
    ]
];
$recipient = new \MailQ\Entities\v2\RecipientEntity($data);
$recipientsListId = 1;
$validate = false;
$mailq->updateRecipient($recipient,$recipientsListId,$validate);
```

#### Get all recipients list unsubscriber

[](#get-all-recipients-list-unsubscriber)

```
$recipientsListId = 1;
$unsubscribers = $mailq->getRecipientListUnsubscribers($recipientsListId);
```

#### Add recipients list unsubscriber

[](#add-recipients-list-unsubscriber)

```
$recipientsListId = 1;
$email = "recipient@example.org";
$mailq->addRecipientListUnsubscriber($emails,$recipientsListId);
```

#### Add recipients list unsubscribers

[](#add-recipients-list-unsubscribers)

```
$data = [
	"emails" => [
		[
			"email" => "recipient@example.org"
		],
		[
			"email" => "recipient2@example.org"
		]
	]
];
$recipientsListId = 1;
$emails = new \MailQ\Entities\v2\EmailAddressesEntity($data);
$mailq->addRecipientListUnsubscribers($emails,$recipientsListId);
```

#### Delete recipients list unsubscriber

[](#delete-recipients-list-unsubscriber)

```
$recipientsListId = 1;
$email = "recipient@example.org";
$mailq->deleteRecipientListUnsubscriber($emails,$recipientsListId);
```

### [SMS Notifications](http://docs.newmailing.apiary.io/#smsnotifications)

[](#sms-notifications)

### Create single SMS notification

[](#create-single-sms-notification)

```
$data = [
	"name" => "SMS notification",
    "code" => "S1",
    "template" => "U01TIHRlc3Qge3t2YXJpYWJsZX19"
];
$smsNotification = new \MailQ\Entities\v2\SmsNotificationEntity($data);
$mailq->createSmsNotification($smsNotification);
$smsNotificationId = $smsNotification->getId();
```

### Update single SMS notification

[](#update-single-sms-notification)

```
$data = [
	"name" => "SMS notification",
    "code" => "S1",
    "template" => "U01TIHRlc3Qge3t2YXJpYWJsZX19"
];
$smsNotification = new \MailQ\Entities\v2\SmsNotificationEntity($data);
$mailq->updateSmsNotification($smsNotification);
```

### Delete SMS notification

[](#delete-sms-notification)

```
$smsNotificationId = 1;
$mailq->deleteSmsNotification($smsNotification);
```

#### Get all SMS notifications

[](#get-all-sms-notifications)

```
$notifications = $mailq->getSmsNotifications();
```

#### Get single SMS notification

[](#get-single-sms-notification)

```
$smsNotificationId = 1;
$notifications = $mailq->getSmsNotification($smsNotificationId);
```

#### Send SMS

[](#send-sms)

```
$smsNotificationId = 1;
$data = [
	"toNumber" => "+420123456789",
    "data" => [
        "key1" => "value1",
        "key2" => "value2"
    ]
];
$sms = new \MailQ\Entities\v2\SmsEntity($data);
$mailq->sendSms($sms,$smsNotificationId);
$smsId = $sms->getId();
```

#### Send SMS batch

[](#send-sms-batch)

```
$smsNotificationId = 1;
$data = [
	"batch" => [
        [
            "id" => 1,
            "toNumber" => "+420123456789",
            "data" => [
                "text" => "value1"
            ]
        ],
        [
            "id" => 2,
            "toNumber" => "+420123456789",
            "data" => [
                "text" => "value2"
            ]
        ]

    ]
];
$smsBatch = new \MailQ\Entities\v2\SmsBatchEntity($data);
$smsBatchResultEntity = $mailq->sendSmsBatch($smsBatch,$smsNotificationId);
```

### [Sender emails](http://docs.newmailing.apiary.io/#senderemails)

[](#sender-emails)

#### Get all sender emails

[](#get-all-sender-emails)

```
$senderEmails = $mailq->getSenderEmails();
```

#### Get single sender email

[](#get-single-sender-email)

```
$senderEmailId = 1;
$senderEmail = $mailq->getSenderEmail($senderEmailId);
```

### [Users](http://docs.newmailing.apiary.io/#users)

[](#users)

#### Get all users

[](#get-all-users)

```
$users = $mailq->getUsers();
```

#### Get single user

[](#get-single-user)

```
$userId = 1;
$user = $mailq->getUser($userId);
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.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 ~79 days

Recently: every ~218 days

Total

27

Last Release

1817d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.5.0

v0.9.0PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/11db767ed593e123c7967efeb1eed03a06dac76d83acf4f347009d1a321d6512?d=identicon)[blazekv](/maintainers/blazekv)

![](https://www.gravatar.com/avatar/0cd94fe263eeb04de274d44e7ef893da328f55dea4825f2039dc56848ba7ee19?d=identicon)[Quanti](/maintainers/Quanti)

---

Top Contributors

[![blazekv](https://avatars.githubusercontent.com/u/5405360?v=4)](https://github.com/blazekv "blazekv (67 commits)")[![kratkyzobak](https://avatars.githubusercontent.com/u/20162433?v=4)](https://github.com/kratkyzobak "kratkyzobak (5 commits)")[![hrabalo](https://avatars.githubusercontent.com/u/1485604?v=4)](https://github.com/hrabalo "hrabalo (2 commits)")[![mstefan21](https://avatars.githubusercontent.com/u/22791905?v=4)](https://github.com/mstefan21 "mstefan21 (2 commits)")[![havranro](https://avatars.githubusercontent.com/u/46903135?v=4)](https://github.com/havranro "havranro (1 commits)")[![maajak](https://avatars.githubusercontent.com/u/4518490?v=4)](https://github.com/maajak "maajak (1 commits)")[![petrjirous](https://avatars.githubusercontent.com/u/2665666?v=4)](https://github.com/petrjirous "petrjirous (1 commits)")

### Embed Badge

![Health badge](/badges/quanti-mailq-connector/health.svg)

```
[![Health](https://phpackages.com/badges/quanti-mailq-connector/health.svg)](https://phpackages.com/packages/quanti-mailq-connector)
```

###  Alternatives

[nette/mail

📧 Nette Mail: A handy library for creating and sending emails in PHP.

5389.8M246](/packages/nette-mail)

PHPackages © 2026

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