PHPackages                             cmdotcom/text-sdk-php - 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. cmdotcom/text-sdk-php

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

cmdotcom/text-sdk-php
=====================

PHP SDK to send messages with CM.com

3.0.2(5mo ago)23680.0k—7.3%64MITPHPPHP ^7.1||^8.0CI passing

Since Feb 27Pushed 4mo ago10 watchersCompare

[ Source](https://github.com/cmdotcom/text-sdk-php)[ Packagist](https://packagist.org/packages/cmdotcom/text-sdk-php)[ Docs](https://www.cm.com/products/text/)[ RSS](/packages/cmdotcom-text-sdk-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (27)Used By (4)

[![GitHub Workflow](https://github.com/cmdotcom/text-sdk-php/actions/workflows/main.yml/badge.svg)](https://github.com/cmdotcom/text-sdk-php/actions/workflows/main.yml)[![codecov](https://camo.githubusercontent.com/35b956065a824640952c42c81a2072460db2e7bad69b471df900d3fb4554dace/68747470733a2f2f636f6465636f762e696f2f67682f636d646f74636f6d2f746578742d73646b2d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/cmdotcom/text-sdk-php)[![Packagist](https://camo.githubusercontent.com/314b926ca4f513998a60aa8fefa5fb39695f4d574b980fde1c2e5c17baf1c0bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f636d646f74636f6d2f746578742d73646b2d706870)](https://packagist.org/packages/cmdotcom/text-sdk-php)

CM Text SDK
===========

[](#cm-text-sdk)

A software development kit to provide ways to interact with CM.com's Text service. API used:

- [Business Messaging](https://developers.cm.com/messaging/docs)

### Requirements

[](#requirements)

- php 7.1 through 8.5 (inclusive)

Usage
-----

[](#usage)

### Instantiate the client

[](#instantiate-the-client)

Using your unique `ApiKey` (or product token) which authorizes you on the CM platform. Always keep this key secret!

The product token can be found in the [Channels](https://www.cm.com/app/channels) application on the platform, under the `Gateway` section.

```
$client = new \CMText\TextClient('your-api-key');
```

### Send a message

[](#send-a-message)

By calling `SendMessage` and providing message text, sender name, recipient phone number(s) and a reference (optional).

```
$result = $client->SendMessage('Message_Text', 'CM.com', [ 'Recipient_PhoneNumber' ], 'Your_Reference');
```

### Get the result

[](#get-the-result)

`SendMessage` and `send` return an object of type `TextClientResult`, example:

```
{
  "statusMessage": "Created 1 message(s)",
  "statusCode": 201,
  "details": [
    {
      "reference": "Example_Reference",
      "status": "Accepted",
      "to": "Example_PhoneNumber",
      "parts": 1,
      "details": null
    },
    {
      "reference": "Example_Reference2",
      "status": "Rejected",
      "to": "Example_PhoneNumber2",
      "parts": 0,
      "details": "A body without content was found"
    }
  ]
}
```

### Status codes

[](#status-codes)

For all possibly returned status codes, please reference the `TextClientStatusCodes` class.

### Sending a rich message

[](#sending-a-rich-message)

By using the `Message` class it is possible to create messages with media for channels such as WhatsApp and RCS

```
$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::WHATSAPP])
    ->WithHybridAppKey('your-secret-hybrid-app-key')
    ->WithRichMessage(
        new MediaMessage(
            'cm.com',
            'https://avatars3.githubusercontent.com/u/8234794?s=200&v=4',
            'image/png'
        )
    )
    ->WithSuggestions([
        new ReplySuggestion('Opt In', 'OK'),
        new ReplySuggestion('Opt Out', 'STOP'),
    ]);
$result = $client->send( [$message] );
```

Sending a WhatsApp template message
-----------------------------------

[](#sending-a-whatsapp-template-message)

By using the `Message` class it is possible to create template messages. Please note that this is WhatsApp only and your template needs to be approved before sending. For more info please check our documentation:

```
$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::WHATSAPP])
    ->WithTemplate(
            new TemplateMessage(
                new WhatsappTemplate(
                    'namespace',
                    'elementname',
                    new Language('en'),
                    [
                        new ComponentBody([
                            new ComponentParameterText('firstname')
                        ])
                    ]
                )
            )
    );
$result = $client->send( [$message] );
```

Sending a rich WhatsApp template message
----------------------------------------

[](#sending-a-rich-whatsapp-template-message)

It is also possible to send a rich template with an image!

```
$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::WHATSAPP])
    ->WithTemplate(
        new TemplateMessage(
            new WhatsappTemplate(
                'template-name',
                'the-namespace-of-template',
                new Language('en'),
                [
                    new ComponentHeader([
                        new ComponentParameterImage(
                            new MediaContent(
                                'image name',
                                'https://image.location',
                                'image/png'
                            )
                        )
                    ]),
                    new ComponentBody([
                        new ComponentParameterText('firstname')
                    ])
                ]
            )
        )
    );
$result = $client->send( [$message] );
```

Sending an Apple Pay Request
----------------------------

[](#sending-an-apple-pay-request)

It is now possible to send an apple pay request only possible in Apple Business Chat

```
$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::IMESSAGE])
    ->WithPayment(
        new PaymentMessage(
            new ApplePayConfiguration(
                'merchant-name',
                'product-description',
                'unique-order-guid',
                1,
                'currency-code',
                'recipient-email',
                'recipient-country-code',
                'language-country-code',
                true,
                true,
                [
                    new LineItem(
                        'product-name',
                        'final-or-pending',
                        1
                    )
                ]
            )
        )
    );
$result = $client->send( [$message] );
```

Sending WhatsApp interactive messages
-------------------------------------

[](#sending-whatsapp-interactive-messages)

It is now possible to send list messages and reply buttons without using templates only supported in WhatsApp

```
$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::WHATSAPP])
    ->WithRichMessage(
        new WhatsAppInteractiveMessage(
            new WhatsAppInteractiveContent(
                WhatsAppInteractiveContentTypes::LIST,
                new WhatsAppInteractiveHeader(
                    WhatsAppInteractiveHeaderTypes::TEXT,
                    'List message example'
                ),
                new WhatsAppInteractiveBody('checkout our list message demo'),
                new WhatsAppInteractiveListAction(
                    'Descriptive list title',
                    [new WhatsAppInteractiveSection(
                        'Select an option',
                        [new WhatsAppInteractiveSectionRow(
                            'unique title 1',
                            rand(),
                            'description text'
                        ),new WhatsAppInteractiveSectionRow(
                            'unique title 2',
                            rand()
                        )]
                    )]
                ),
                new WhatsAppInteractiveFooter('footer text')
            )
        )
    );
$result = $client->send( [$message] );
```

Only with Reply buttons you can send media like image,video or document see following example.

```
$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::WHATSAPP])
    ->WithRichMessage(
        new WhatsAppInteractiveMessage(
            new WhatsAppInteractiveContent(
                WhatsAppInteractiveContentTypes::BUTTON,
                new WhatsAppInteractiveHeader(
                    WhatsAppInteractiveHeaderTypes::IMAGE,
                    null,
                    new MediaContent(
                        'media name',
                        'media.url',
                        'mime/type'
                    )
                ),
                new WhatsAppInteractiveBody('checkout our list message demo'),
                new WhatsAppInteractiveButtonAction(
                    [new WhatsAppInteractiveReplyButton(
                        'button 1 reply-text',
                        rand()
                    ),new WhatsAppInteractiveReplyButton(
                        'button 2 title',
                        rand()
                    )]
                ),
                new WhatsAppInteractiveFooter('footer text')
            )
        )
    );
$result = $client->send( [$message] );
```

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance75

Regular maintenance activity

Popularity48

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~112 days

Recently: every ~135 days

Total

23

Last Release

157d ago

Major Versions

1.2.2 → 2.0.02020-10-02

2.3.1 → 3.0.02024-12-31

PHP version history (3 changes)1.0.0PHP ^7.0

2.0.3PHP ^7.0||^8.0

3.0.0PHP ^7.1||^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/49b0e2ee0e430838dda4a35956501cd7067d62d4b26e1984dbcec86491af5114?d=identicon)[hexonthebeach](/maintainers/hexonthebeach)

---

Top Contributors

[![hexonthebeach](https://avatars.githubusercontent.com/u/30188524?v=4)](https://github.com/hexonthebeach "hexonthebeach (36 commits)")[![tomodutch](https://avatars.githubusercontent.com/u/4613944?v=4)](https://github.com/tomodutch "tomodutch (3 commits)")[![robinvoogt](https://avatars.githubusercontent.com/u/82213867?v=4)](https://github.com/robinvoogt "robinvoogt (2 commits)")[![ganboonhong](https://avatars.githubusercontent.com/u/10766871?v=4)](https://github.com/ganboonhong "ganboonhong (1 commits)")[![bgijzen](https://avatars.githubusercontent.com/u/10259246?v=4)](https://github.com/bgijzen "bgijzen (1 commits)")[![michaelvdnet](https://avatars.githubusercontent.com/u/1355285?v=4)](https://github.com/michaelvdnet "michaelvdnet (1 commits)")[![neodc](https://avatars.githubusercontent.com/u/304141?v=4)](https://github.com/neodc "neodc (1 commits)")[![joepb](https://avatars.githubusercontent.com/u/5315418?v=4)](https://github.com/joepb "joepb (1 commits)")[![dennisenderink](https://avatars.githubusercontent.com/u/329734?v=4)](https://github.com/dennisenderink "dennisenderink (1 commits)")[![EnessenE](https://avatars.githubusercontent.com/u/9263360?v=4)](https://github.com/EnessenE "EnessenE (1 commits)")

---

Tags

cmimessagelinemessagingpushrcssmstextviberwechatwhatsappinstagramsmstwitterwhatsappwechatlineviberrcsIMessagecm.com

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cmdotcom-text-sdk-php/health.svg)

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

###  Alternatives

[mageplaza/module-smtp

SMTP Extension for Magento 2 helps the owner of store simply install SMTP (Simple Mail Transfer Protocol) server which transmits the messages into codes or numbers

3015.9M8](/packages/mageplaza-module-smtp)[infobip/infobip-api-php-client

PHP library for consuming Infobip's API

921.8M10](/packages/infobip-infobip-api-php-client)

PHPackages © 2026

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