Download the PHP package webfiori/mailer without Composer

On this page you can find all versions of the php package webfiori/mailer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mailer

WebFiori Mailer

Sockets-based library for sending HTML email messages.

PHP 8.1+

Table of Contents

Motivation

HTML-First Composition

Most mailing libraries treat the email body as a string you pass in. WebFiori Mailer treats emails as HTML documents you build using a virtual DOM. You compose emails the same way you'd build a web page — inserting elements, nesting children, setting styles programmatically:

No raw HTML strings. No template engine required (though templates are supported too).

Minimal Dependencies

The library relies only on two lightweight packages (webfiori/ui for DOM building and webfiori/file for attachments). The SMTP layer is built directly on PHP sockets. No heavy third-party dependencies to keep up with.

Built-in Testing Modes

Testing emails shouldn't require actually sending them or setting up third-party services:

Switch between modes with a single call:

SMTP Transparency

Every command sent to the SMTP server is logged with its response code and message. When something fails, you see exactly what happened at the protocol level — no black-box debugging.

Lightweight and Self-Contained

The entire library is a handful of classes. If all you need is to send HTML emails over SMTP without pulling in a large framework or dozens of transitive dependencies, this gets the job done.

Supported PHP Versions

Build Status

Installation

Quick Start

Usage

Basic Usage

Connecting to SMTP Server

Connection information is represented using an instance of the class WebFiori\Mail\SMTPAccount.

Creating Email Message

Setting Email Subject

Adding a Recipient

Writing HTML Content

The email messages are HTML based, utilizing the library webfiori/ui to build the virtual DOM.

Sending The Message

Fluent Interface

WebFiori Mailer supports method chaining for a more readable and concise syntax:

Available fluent methods:

OAuth Authentication

WebFiori Mailer supports OAuth2 authentication via the OAuthTokenProvider interface. Built-in providers handle token acquisition, caching, and refresh automatically. The token is fetched lazily — just before each send — so it is always fresh.

Microsoft 365 / Outlook (MicrosoftOAuthProvider)

Uses the Client Credentials flow against Microsoft Entra ID. No user interaction required.

Custom provider

Implement OAuthTokenProvider for any other OAuth2-capable SMTP server:

See the OAuth examples for complete setup instructions.

Amazon SES SMTP (SESCredentialHelper)

Amazon SES SMTP uses IAM credentials, not OAuth. SESCredentialHelper derives the required SMTP password from your IAM Secret Access Key:

No special transport needed — SES SMTP uses standard AUTH LOGIN. See the SES example for full details.

SSL/TLS Verification

By default, SSL/TLS peer verification is enabled for all connections. This means:

This is the correct and secure default for any publicly trusted SMTP server.

Internal servers with self-signed certificates

Disable verification entirely (not recommended for production)

Warning: Setting VERIFY_SSL to false exposes SMTP credentials to man-in-the-middle attacks. Only use it in isolated/controlled environments.

See the SSL configuration example for a full demonstration.

Connection Retry and Timeout

Failed connections are automatically retried with exponential backoff. The read timeout applies to every fgets() call after the connection is established, preventing indefinite hangs when a server becomes unresponsive mid-session.

Option Default Description
AccountOption::MAX_RETRIES 3 Number of reconnect attempts after failure
AccountOption::RETRY_DELAY 1 Base delay in seconds between attempts (doubles each retry)

Backoff schedule with defaults: attempt 1 immediate, attempt 2 waits 1s, attempt 3 waits 2s, attempt 4 waits 4s.

Note: Retries only apply to TCP connection establishment. A SMTPException thrown during read() due to a timeout means the session state is unknown and cannot be safely retried in place — the caller should reconnect from scratch.

See ADR-0032 for the full design rationale.

Message-ID and Reply Threading

Every sent email automatically gets a unique Message-ID header (RFC 5322). After calling send(), you can read it back:

To send a reply that threads correctly in email clients, set the In-Reply-To header:

Attachments

Attachments can be added using Email::addAttachment(). The parameter can be a file path string or an object of type webfiori\file\File.

Before Send Callback

Execute logic before the message is sent using Email::addBeforeSend():

After Send Callback

Execute logic after the message is sent using Email::addAfterSend():

Accessing SMTP Log

Every SMTP command is logged with its response code and message. Access log events via Email::getLog():

Storing Email

Emails can be stored as HTML web pages for preview purposes:

This will:

image

Testing Modes

The library provides two testing modes controlled by Email::setMode():

Store as Web Pages

Send to Test Addresses

Examples

Comprehensive examples are available in the examples/ directory:

Testing

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This library is licensed under the MIT License. See the LICENSE file for more details.

Support

If you encounter any issues, please open an issue on GitHub.

Changelog

See CHANGELOG.md for a list of changes.


All versions of mailer with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
webfiori/file Version 2.1.*
webfiori/ui Version 4.0.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webfiori/mailer contains the following files

Loading the files please wait ...