PHPackages                             desttools/transmail - 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. desttools/transmail

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

desttools/transmail
===================

ZeptoMail / TransMail Email Client Library for PHP

v1.1(5y ago)24922MITPHPPHP ^5.6.0 || ^7.0

Since Oct 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/desttools/transmail)[ Packagist](https://packagist.org/packages/desttools/transmail)[ Docs](https://www.zoho.com/transmail/)[ RSS](/packages/desttools-transmail/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)DependenciesVersions (4)Used By (0)

Zoho ZeptoMail API PHP Client (formerly TransMail)
==================================================

[](#zoho-zeptomail-api-php-client-formerly-transmail)

Generic PHP API Client for Zoho's ZeptoMail service

This unofficial ZeptoMail/Transmail PHP library allows you to easily send transactional email messages via the [Zoho ZeptoMail API](https://www.zoho.com/zeptomail/).

The ZeptoMail system is intended for transactional emails related to website and app interactions (receipts, password resets, 2FA notices, etc.), not bulk sending of emails like newsletters and announcements. Please see the [ZeptoMail site](https://www.zoho.com/zeptomail/) for details about use cases and guidelines.

Developer Note
--------------

[](#developer-note)

This library was created when this service was called Transmail. Other than the name on the Zoho documentation and a new API endpoint, the API is identical as before and as of this writing in August 2021 it continues to work even with the old Transmail endpoint. At some point in the future, I plan to update this library to reflect the new branding. Until then, it will continue to be used and namespaced as "transmail"

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

[](#installation)

For most uses we recommend installing the [desttools/transmail](https://packagist.org/packages/desttools/transmail) package via Composer. If you have [Composer](https://getcomposer.org) installed already, you can add the latest version of the package with the following command:

```
composer require desttools/transmail

```

Or if you're adding this library to an application, in your composer.json file

```
"require": {
	"desttools/transmail": "dev-master"
},

```

Alternately, you can simply [clone this repository](https://github.com/desttools/transmail.git) directly to include the source code in your project.

Settings
--------

[](#settings)

Before you can connect to the API, you'll need two settings from your ZeptoMail account: an **authorization key** and a **bounce address**

If you are using an environment file, you'll want to create settings with these setting:

```
transmailkey = "MyAPIkeyfromZeptoMail"
transbounceaddr = "bounce@bounce.mydomain.com"

```

If you aren't using environment variables in your application, you can omit this step and pass these settings directly to the mailer (see full example below).

To load the library in your page or app, you'll need to include the file:

```
// doing your own loading:
include_once ("./transmail/TransmailClient.php");

// or if using composer autoloading:
include_once ('./vendor/autoload.php');
```

Note: Your ability to send messages also requires that the sender's domain is pre-verified in your ZeptoMail dashboard. Without that, you will see authentication errors.

Basic Mailing Example:
----------------------

[](#basic-mailing-example)

```
//create a new message object
$msg = new \stdClass();

//required settings
$msg->subject = "My message subject"; //SUBJECT
$msg->textbody = "My text-only message"; //TEXT MSG, NULL IF sending HTML
$msg->htmlbody = "My HTML-formatted message"; //HTML MSG, NULL if sending TEXT
$msg->to = array('joe@customer.com','Joe Customer'); //TO
$msg->from = array('support@site.com','XYZ Company'); //FROM

//instantiate library and pass info
$tmail = new \Transmail\TransmailClient($msg);

//send the message
$response = $tmail->send();

if ($response)
{
// success
}
else
{
// failure
}
```

Note: You can pass all email addresses either as a string or as an array, like this:

```
$msg->to = 'joe@customer.com';
//or
$msg->to = array('joe@customer.com','Joe Customer');
```

If using an array, the formatter will look for the email address in either the first or second element position. If it finds an address, it will use the remaining element as the text name. If additional elements are passed here they will be ignored.

Full Example
------------

[](#full-example)

Below are ALL the possible options, including manually setting an authorization key and bounce address:

```
	//create a new message object
	$msg = new \stdClass();

	//required settings
	$msg->subject = "My message subject"; //SUBJECT
	$msg->textbody = "My text-only message"; //TEXT MSG, NULL IF sending HTML
	$msg->htmlbody = "My HTML-formatted message"; //HTML MSG, NULL if sending TEXT
	$msg->to = array('joe@customer.com','Joe Customer'); //TO
	$msg->from = array('support@site.com','XYZ Company'); //FROM

	//optional settings
	$msg->reply_to = array('address@site.com','XYZ Company'); //REPLY TO
	$msg->cc = array('address2@site.com','Someone'); //CC
	$msg->bcc = array('address3@site.com','Somebody Else'); //BCC
	$msg->track_clicks = TRUE; //TRACK CLICKS, TRUE by default
	$msg->track_opens = TRUE; //TRACK OPENS, TRUE by default
	$msg->client_reference = NULL; //CLIENT ID (string)
	$msg->mime_headers = NULL; //ADDITIONAL MIME HEADERS (array)
	$msg->attachments = NULL; //ATTACHMENTS (array)
	$msg->inline_images = NULL; //INLINE IMAGES (array)

	//instantiate library and pass all possible settings
	$tmail = new \Transmail\TransmailClient($msg, "myapikey", "mybounce@address.com", TRUE);

	//send the message
	$response = $tmail->send();

	if ($response)
	{
		// success
	}
	else
	{
		// failure
	}
```

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

[](#error-handling)

When you actually load the library, there is a 4th parameter that can be passed to turn on verbose error reporting. By default, this is off and the function returns **TRUE** (message sent) and **FALSE** (message not sent).

There are two main possible points of failure that can occur: The cURL request could fail, or the API request could fail. In both cases, the function will return a generic **FALSE** unless you have verbose errors turned on.

### With Verbose Errors Turned On:

[](#with-verbose-errors-turned-on)

In the event of a cURL error, a string will be returned with the specific PHP error code.

In the event of API success or failure, a JSON object with the entire API response will be returned. Consult the ZeptoMail documentation for error codes and other details about these messages.

[ZeptoMail API Error Codes](https://www.zoho.com/zeptomail/help/api/error-codes.html)

**Security Note: These verbose messages could divulge sensitive info about your site or your ZeptoMail account, so errors should be captured or turned off in a production setting**.

Additional Headers
------------------

[](#additional-headers)

Passing additional headers to the email server is possible. Simply create any name-value pairs you want as an array and pass that to the function

```
$headers = array();

$headers[] = array( "CustId"   => "1234",
		    "CustName" => "Bob Smith" );
```

Sending Attachments
-------------------

[](#sending-attachments)

Sending attachments means loading the file into PHP's memory, converting to a Base64-encoded stream and then passing that to the function. Since there are three parameters needed by ZeptoMail, it is generally advised to first set up the attachments as an array and then pass that to the function:

```
$attachments = array();

$file = "filename.jpg";
$path = "/path/to/" . $file;
$filedata = file_get_contents($path);

if ($filedata)
{

$base64 = base64_encode($filedata);

$attachments[] = array( "content"   => $base64,
			"mime_type" => mime_content_type($path),
			"name"      => $file );

}
```

[List of unsupported attachments](https://www.zoho.com/zeptomail/help/file-cache.html#alink-un-sup-for)

### [Zoho ZeptoMail API Documentation](https://www.zoho.com/zeptomail/help/introduction.html)

[](#zoho-zeptomail-api-documentation)

NOTE: This library only sends messages through the ZeptoMail API system. If you are attempting to send via SMTP, please consult the documentation for your web or email server's mail program for SMTP relaying.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

Total

2

Last Release

2043d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4dadb75e8fd685ecabfc694be040af9dd6f2def374c18fe3701d30f9f4aac1af?d=identicon)[desttools](/maintainers/desttools)

---

Top Contributors

[![desttools](https://avatars.githubusercontent.com/u/48933204?v=4)](https://github.com/desttools "desttools (25 commits)")

---

Tags

transactional-emailstransmail-apizoho-transmail-serviceemailZohodeliverabilitytransmail

### Embed Badge

![Health badge](/badges/desttools-transmail/health.svg)

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

###  Alternatives

[egulias/email-validator

A library for validating emails against several RFCs

11.6k691.3M307](/packages/egulias-email-validator)[sendgrid/sendgrid

This library allows you to quickly and easily send emails through Twilio SendGrid using PHP.

1.5k47.5M164](/packages/sendgrid-sendgrid)[pelago/emogrifier

Converts CSS styles into inline style attributes in your HTML code

94944.1M110](/packages/pelago-emogrifier)[zbateson/mail-mime-parser

MIME email message parser

54149.2M79](/packages/zbateson-mail-mime-parser)[soundasleep/html2text

A PHP script to convert HTML into a plain text format

48519.5M75](/packages/soundasleep-html2text)[opcodesio/mail-parser

Parse emails without the mailparse extension

226.8M8](/packages/opcodesio-mail-parser)

PHPackages © 2026

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