PHPackages                             messagex/email-php-sdk - 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. messagex/email-php-sdk

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

messagex/email-php-sdk
======================

PHP SDK to integrate with MessageX Email service

v1.0(8y ago)14.4kMITPHP

Since Dec 4Pushed 8y ago5 watchersCompare

[ Source](https://github.com/messagex/messagex-email-php-sdk)[ Packagist](https://packagist.org/packages/messagex/email-php-sdk)[ Docs](https://www.messagex.com)[ RSS](/packages/messagex-email-php-sdk/feed)WikiDiscussions master Synced 3d ago

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

MessageX Email PHP SDK
======================

[](#messagex-email-php-sdk)

Introduction
============

[](#introduction)

Official SDK for MessageX Email API. It's goal is to provide easy integration with MessageX Email Service in PHP and build robust applications and software with those services. We want this SDK to be community driven and led by us. You can get started in minutes by installing SDK through composer or downloading a zip file.

Request Size
------------

[](#request-size)

When sending attachments there are no explicit file size limitations. Requests bigger then 30MB will be reject with HTTP 417 status code.

Error Handling
--------------

[](#error-handling)

All exceptions in SDK extend base MxException for easier handling of all exceptions rising from SDK. For more granular error handling email service has it's own base exception called EmailException.

### Transport Errors

[](#transport-errors)

For sending requests MessageX PHP SDK is using Guzzle HTTP Client. When API returns with status code other then 2\*, Guzzle will throw exception depending on the group of status code (Server side, Client side). Guzzle related exceptions are not handled in SDK.

Prerequisites
=============

[](#prerequisites)

- PHP &gt;= 5.6
- API and Secret Key from your MessageX account

Installation
============

[](#installation)

### Composer

[](#composer)

Add following to the composer.json file

```
    {
        "require": {
            "messagex/email-php-sdk": "~1.0"
        }
    }
```

Or from the CLI

```
composer require messagex/email-php-sdk
```

Quickstart
==========

[](#quickstart)

Send an Email
-------------

[](#send-an-email)

This is a minimal code sample needed in order to send a basic email using SDK.

```
require 'vendor/autoload.php';

use MessageX\Service\Email\ValueObject\Email;
use MessageX\Service\Email\ValueObject\Body\Body;
use MessageX\Service\Email\EmailClient;

$emailClient = new EmailClient([
        'credentials' => ['key' => 'XXXXX', 'secret' => 'XXXXX']
    ]);

$emailClient->sendEmail(
    (new Email('John Doe ', ['Jane Doe ']))
        ->setSubject('Greetings')
        ->addBody(new Body('text/plain', 'Hi Jane))
);
```

Name of the receiver or sender can be added using notation showed in code sample above. Adding a name is not required, adding just email address is also supported. At the moment only following content types are support for the email body

- text/html
- text/plain

Add CC and BCC
--------------

[](#add-cc-and-bcc)

Adding CC and BCC is also simple as

```
require 'vendor/autoload.php';

use MessageX\Service\Email\ValueObject\Email;
use MessageX\Service\Email\ValueObject\Body\Body;
use MessageX\Service\Email\EmailClient;

$emailClient = new EmailClient([
        'credentials' => ['key' => 'XXXXX', 'secret' => 'XXXXX']
    ]);

$emailClient->sendEmail(
    (new Email('John Doe ', ['Jane Doe ']))
        ->setSubject('Greetings')
        ->addBcc(['John Doe '])
        ->addCc(['John Doe '])
        ->addBody(new Body('text/plain', 'Hi Jane'))
);
```

Same rules applies regarding email address and names as in the first example.

Add Attachment
--------------

[](#add-attachment)

You can add one or more attachments to the email as following

```
require 'vendor/autoload.php';

use MessageX\Service\Email\ValueObject\Email;
use MessageX\Service\Email\ValueObject\Body\Body;
use MessageX\Service\Email\ValueObject\Attachment\Attachment;
use MessageX\Service\Email\EmailClient;

$emailClient = new EmailClient([
        'credentials' => ['key' => 'XXXXX', 'secret' => 'XXXXX']
    ]);

$emailClient->sendEmail(
    (new Email('John Doe ', ['Jane Doe ']))
        //... Code removed
        ->addAttachment(Attachment::fromFile('path/to/file.pdf'))
);
```

Custom Tags
-----------

[](#custom-tags)

Tags are custom text labels associated with the the email. Maximum number of tags that can be added is 5. Add you custom tags as showed in sample below

```
require 'vendor/autoload.php';

use MessageX\Service\Email\ValueObject\Email;
use MessageX\Service\Email\ValueObject\Body\Body;
use MessageX\Service\Email\ValueObject\Attachment\Attachment;
use MessageX\Service\Email\EmailClient;

$emailClient = new EmailClient([
        'credentials' => ['key' => 'XXXXX', 'secret' => 'XXXXX']
    ]);

$emailClient->sendEmail(
    (new Email('John Doe ', ['Jane Doe ']))
        //... Code removed
        ->addTag('Tag1')
);
```

Custom Headers
--------------

[](#custom-headers)

Also custom headers will be added to the email and sent to the recipients. Maximum number of custom headers that can be added is 5. Add custom headers as shown in sample below

```
require 'vendor/autoload.php';

use MessageX\Service\Email\ValueObject\Email;
use MessageX\Service\Email\ValueObject\Body\Body;
use MessageX\Service\Email\ValueObject\Attachment\Attachment;
use MessageX\Service\Email\EmailClient;

$emailClient = new EmailClient([
        'credentials' => ['key' => 'XXXXX', 'secret' => 'XXXXX']
    ]);

$emailClient->sendEmail(
    (new Email('John Doe ', ['Jane Doe ']))
        //... Code removed
        ->addHeader('X-Custom-Header', 'Value')
);
```

Mail Merge
----------

[](#mail-merge)

Properties are representing placeholder strings in email body and value for each property is array of replacements for all recipients. Number of replacements for each placeholder must match number of recipients. Order of replacements for each placeholder must match order of recipients. Mail merge can be added as shown in the sample below

```
require 'vendor/autoload.php';

use MessageX\Service\Email\ValueObject\Email;
use MessageX\Service\Email\ValueObject\Body\Body;
use MessageX\Service\Email\ValueObject\Attachment\Attachment;
use MessageX\Service\Email\EmailClient;

$emailClient = new EmailClient([
        'credentials' => ['key' => 'XXXXX', 'secret' => 'XXXXX']
    ]);

$emailClient->sendEmail(
    (new Email('John Doe ', ['Jane Doe ', 'Alice Doe ']))
        //... Code removed
        ->addBody(new Body('text/plain', 'Hi {{name}}'))
        ->addSubstitution('name', ['Jane', 'Alice'])
);
```

Documentation
-------------

[](#documentation)

SDK Reference
-------------

[](#sdk-reference)

API Reference
-------------

[](#api-reference)

Getting help
------------

[](#getting-help)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

Unknown

Total

1

Last Release

3083d ago

### Community

Maintainers

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

---

Top Contributors

[![sahilsaggar](https://avatars.githubusercontent.com/u/9360496?v=4)](https://github.com/sahilsaggar "sahilsaggar (2 commits)")

---

Tags

phpsdkemaillibraryMXmessagex

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/messagex-email-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/messagex-email-php-sdk/health.svg)](https://phpackages.com/packages/messagex-email-php-sdk)
```

###  Alternatives

[railsware/mailtrap-php

The Mailtrap SDK provides methods for all API functions.

56770.5k](/packages/railsware-mailtrap-php)[stymiee/email-validator

A robust PHP 7.4+ email validation library that extends beyond basic validation with MX record checks, disposable email detection, and free email provider validation. Features include strict typing, custom validator support, internationalization (i18n), and an extensible architecture. Perfect for applications requiring thorough email verification with customizable validation rules.

32426.6k1](/packages/stymiee-email-validator)[mailerlite/mailerlite-api-v2-php-sdk

MailerLite API v2 PHP SDK

801.7M15](/packages/mailerlite-mailerlite-api-v2-php-sdk)[hafael/azure-mailer-driver

Supercharge your Laravel or Symfony app with Microsoft Azure Communication Services (ACS)! Effortlessly add email, chat, voice, video, and telephony-over-IP for next-level communication. 🚀

14109.2k](/packages/hafael-azure-mailer-driver)[henrique-borba/php-sieve-manager

A modern (started in 2022) PHP library for the ManageSieve protocol (RFC5804) to create/edit Sieve scripts (RFC5228). Used by Cypht Webmail.

23125.7k2](/packages/henrique-borba-php-sieve-manager)

PHPackages © 2026

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