PHPackages                             benjosiah/smtp-express-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. benjosiah/smtp-express-php

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

benjosiah/smtp-express-php
==========================

PHP package for sending emails using SMTP Express API.

1.0.0(1y ago)041MITPHPPHP ^8.0

Since Apr 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/benjosiah/smtp-express-php-sdk)[ Packagist](https://packagist.org/packages/benjosiah/smtp-express-php)[ RSS](/packages/benjosiah-smtp-express-php/feed)WikiDiscussions main Synced 1mo ago

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

SMTP Express PHP SDK
====================

[](#smtp-express-php-sdk)

The **SMTP Express PHP SDK** provides a simple, extensible way to send emails using the [SMTP Express](https://smtpexpress.com) API from any PHP application.

> 🚀 Lightweight, flexible, and built with Guzzle for efficient HTTP communication.

---

✨ Features
----------

[](#-features)

- Send standard HTML emails: You can compose and send emails with HTML content to make them visually appealing.
- Send emails using templates with dynamic variables: This feature lets you create reusable email templates where specific parts of the email can be customized with different information each time you send it. For example, you can personalize greetings or include order details.
- Add calendar event invites: You can easily include calendar invites directly within your emails, making it convenient for recipients to add events to their calendars.
- Built-in support for sender and recipient metadata: The SDK helps manage information about who is sending the email and who is receiving it.
- PSR-4 autoloading: This is a technical detail that ensures the SDK's components are automatically loaded when needed in your PHP project, making it easier to use.

---

📦 Installation
--------------

[](#-installation)

To start using the SMTP Express PHP SDK in your project, you need to install it using Composer, a common dependency management tool for PHP. Open your project's terminal and run the following command:

```
composer require benjosiah/smtp-express-php
```

🔧 Configuration
---------------

[](#-configuration)

Before you can send emails, you need to configure the SDK with your SMTP Express project secret. This secret authenticates your application with the SMTP Express API. In your PHP code, you'll need to include the autoloader (which was set up during installation) and then create an instance of the SmtpExpress class, providing your project secret:

```
use SmtpExpress\SmtpExpress;
require 'vendor/autoload.php';

$smtp = new SmtpExpress('your-project-secret');
```

Make sure to replace 'your-project-secret' with the actual secret key from your SMTP Express account.

🚀 Usage
-------

[](#-usage)

```
```

### 1. 📄 Send Plain Text or HTML Message

[](#1--send-plain-text-or-html-message)

You can create a new SendMail object, set the subject, the email content (which can be plain text or HTML), the sender's email and name, and the recipient's email and name. Then, use the $smtp-&gt;sendEmail() method to send the email

```
use SmtpExpress\Mail\SendMail;

$email = (new SendMail())
    ->subject('Welcome To Express')
    ->message('Hello from SMTP ExpressEnjoy fast email delivery!')
    ->sender('josiah@smtpexpress.email', 'SMTP SERVER')
    ->recipients('recipient@example.com', 'Ben Josiah');

$response = $smtp->sendEmail($email);
```

### 2. 🧩 Send Custom HTML Template

[](#2--send-custom-html-template)

If you have custom HTML templates for your emails, you can load these templates, replace placeholders (like {{ name }}) with actual data, and then send the resulting HTML as the email body. In this example, the email.html file would contain your HTML template with placeholders like {{ name }}.

```

Welcome, {{ name }}!
We're excited to have you at {{ company }}.
Click here to reset your password.
```

```
use SmtpExpress\Mail\SendMail;
use SmtpExpress\Templates\Template;
use SmtpExpress\Templates\TemplateRenderer;

// Load HTML template
$template = new Template(file_get_contents('email.html'));

// Render with variables
$renderer = new TemplateRenderer();
$html = $renderer->render($template, [
    'name' => 'Josiah',
    'company' => 'SMTPExpress Inc.',
    'url' => 'https://yourapp.com/reset-password'
]);

// Build email
$email = (new SendMail())
    ->subject('Welcome To Express')
    ->message($html)
    ->sender('josiah@smtpexpress.email', 'SMTP SERVER')
    ->recipients('recipient@example.com', 'Ben Josiah');

$response = $smtp->sendEmail($email);
```

### 3. 🧠 Send SMTP Express Template

[](#3--send-smtp-express-template)

If you are using templates stored directly within your SMTP Express account, you can refer to them by their ID and provide the necessary data for the dynamic parts of the template.

Replace 'template-id' with the actual ID of your SMTP Express template.

```
use SmtpExpress\Mail\SendMail;

$templateEmail = (new SendMail())
    ->subject('A Template message from the express')
    ->template('template-id', [
        'name' => 'Josiah',
        'company' => 'SMTP Express',
        'url'=> 'https://yourapp.com/reset-password'
    ])
    ->sender('josiah@smtpexpress.email', 'SMTP SERVER')
    ->recipients('recipient@example.com', 'Ben Josiah');

$response = $smtp->sendEmail($templateEmail);
```

### 4. 📅 Send Calendar Event Email

[](#4--send-calendar-event-email)

To send an email with a calendar event invite, you can use the calendarEvent() method, providing the event title, start time, and end time. The date and time should be provided in ISO 8601 format (e.g., YYYY-MM-DDTHH:MM:SS.SSSZ).

```
use SmtpExpress\Mail\SendMail;

$calendarEmail = (new SendMail())
    ->subject('Strategy Sync-up')
    ->message('Let’s meet to discuss our project roadmap.')
    ->sender('josiah@smtpexpress.email', 'SMTP SERVER')
    ->recipients('recipient@example.com', 'Ben Josiah')
    ->calendarEvent(
        'Strategy Sync-up',
        '2024-01-18T23:00:00.000Z',
        '2024-01-19T23:00:00.000Z'
    );

$response = $smtp->sendEmail($calendarEmail);
```

❗ Error Handling
----------------

[](#-error-handling)

The SDK provides a SmtpExpressException that you can catch to manage these situations.

```
use SmtpExpress\Exception\SmtpExpressException;

try {
    $smtp->sendEmail($email);
} catch (SmtpExpressException $e) {
    echo 'Failed to send: ' . $e->getMessage();
}
```

📁 Project Structure
-------------------

[](#-project-structure)

```
.
├── src/
│   ├── Mail/
│   │   └── SendMail.php
│   ├── Templates/
│   │   ├── Template.php
│   │   └── TemplateRenderer.php
│   ├── Exception/
│   │   └── SmtpExpressException.php
│   └── SmtpExpress.php

```

📝 License
---------

[](#-license)

The SMTP Express PHP SDK is released under the MIT license © Josiah

💬 Feedback or Support?
----------------------

[](#-feedback-or-support)

Email

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance47

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% 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

392d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d7ccc02fa97a1371be5192e9f8a1d6eb8bf893fd550e5dc9a365abe79a52249?d=identicon)[Ben Josiah](/maintainers/Ben%20Josiah)

---

Top Contributors

[![bendev-w](https://avatars.githubusercontent.com/u/248917658?v=4)](https://github.com/bendev-w "bendev-w (8 commits)")[![Gracienigma](https://avatars.githubusercontent.com/u/183556389?v=4)](https://github.com/Gracienigma "Gracienigma (1 commits)")

### Embed Badge

![Health badge](/badges/benjosiah-smtp-express-php/health.svg)

```
[![Health](https://phpackages.com/badges/benjosiah-smtp-express-php/health.svg)](https://phpackages.com/packages/benjosiah-smtp-express-php)
```

###  Alternatives

[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[guanguans/notify

Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

682104.9k7](/packages/guanguans-notify)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)

PHPackages © 2026

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