PHPackages                             bedeabza/bdz-html-email - 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. bedeabza/bdz-html-email

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

bedeabza/bdz-html-email
=======================

Zend Framework 2 module for sending HTML emails using ZF2 layouts

4713PHP

Since Sep 15Pushed 13y ago2 watchersCompare

[ Source](https://github.com/bedeabza/BdzHtmlEmail)[ Packagist](https://packagist.org/packages/bedeabza/bdz-html-email)[ RSS](/packages/bedeabza-bdz-html-email/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

HTML Email module for Zend Framework 2
======================================

[](#html-email-module-for-zend-framework-2)

The main purpose of this module is to provide a simple way of sending HTML emails using ZF2 views as templates, while keeping the many advantages of being able to interact directly with the objects in the `zendframework/mail` package. The module handles the HTML rendering of templates and offers the possibility of retrieving the `\Zend\Mail\Message` and `\Zend\Mail\Transport` instances to manipulate them further.

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

[](#installation)

### Composer

[](#composer)

Add the following to your `composer.json` file:

```
"require": {
    "bedeabza/bdz-html-email": "dev-master"
}
```

Then run `php composer.phar install`

### Manually

[](#manually)

In order to start using the module clone the repo in your vendor directory or add it as a submodule if you're already using git for your project:

```
git clone git@github.com:bedeabza/BdzHtmlEmail.git vendor/BdzHtmlEmail
or
git submodule add git@github.com:bedeabza/BdzHtmlEmail.git vendor/BdzHtmlEmail

```

The module will also be available as a Composer package soon.

The last thing that needs to be done is adding it to your application's list of active modules. For this, add the `BdzHtmlEmail` key in the `modules` array of your `config/application.config.php`

Configuration
-------------

[](#configuration)

The module configuration is based entirely on the new DIC of ZF2. The default configuration uses Sendmail as default transport, but you can override this in your app's configuration. There is also a file `module.config.php.smtp-sample` which shows how the SMTP configuration should be done, but don't modify configuration in the vendor directory, use your own application or other module's configuration to override the default settings.

Also, the entire configuration is based on aliases, so you can swap any of the classes used by the module with your own if you whish to extend it.

One of the first things to do is adding your own views directory to the configuration, so your `module/Application/config/module.config.php` could contain the following:

```
return array(
    'di' => array(
        'instance' => array(
            'bdz-email' => array(
                'parameters' => array(
                    'viewsDir'  => array(
                        dirname(__DIR__) . '/view/email'
                    )
                )
            )
        )
    )
);
```

The template lookup is using a stack, so you can use templates from multiple modules, just keep the file names different.

Also, the default template for emails is the example.phtml shipped with the module, you can override this in the parameters using the `template` key or by calling setTemplate() on the email object at runtime.

Usage
-----

[](#usage)

There are 2 ways of obtaining an email object: using the factory, or configuring it by yourself. (the examples happen in the controller)

### Factory

[](#factory)

```
$email = $this->getServiceLocator()->get('bdz-email-factory')->create(array(
    'from' => array('email@domain', 'John Doe'),
    'subject' => 'Email subject',
    'template' => 'default'
));
```

### Manually

[](#manually-1)

```
$email = $this->getServiceLocator()->get('di')->newInstance('bdz-email');
$email->setFrom('email@domain', 'John Doe');
$email->setSubject('Email subject');
$email->setTemplate('default');
```

All of the above params are also injectable through the DI configuration, so it's up to you how you want to use it.

The email object also provides a way to retrieve or replace the `\Zend\Mail\Message` and the `\Zend\Mail\Transport\TransportInterface` objects:

```
$message = $email->getMessage();
$transport = $email->getTransport();
```

The Email class implements the `proxy` pattern, so that any method called that doesn't exist in `\BdzHtmlEmail\Email` will be proxied to the underlying message object.

Sending the email can also be done in 2 ways:

```
// 1
$email->send(array('firstTemplateParam' => 'value'), 'email@domain', 'Receiver Name');

// 2
$email->setTo('email@domain', 'Receiver Name');
$email->send(array('firstTemplateParam' => 'value'));
```

In both of the above use cases the name parameter is not compulsory. Also if your template doesn't require any variables, you can just call `send()`.

Get in touch
------------

[](#get-in-touch)

You can contact me at bedeabza at gmail dot com or send pull requests for the repo.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/460659?v=4)[D Badea](/maintainers/bedeabza)[@bedeabza](https://github.com/bedeabza)

---

Top Contributors

[![bedeabza](https://avatars.githubusercontent.com/u/460659?v=4)](https://github.com/bedeabza "bedeabza (16 commits)")

### Embed Badge

![Health badge](/badges/bedeabza-bdz-html-email/health.svg)

```
[![Health](https://phpackages.com/badges/bedeabza-bdz-html-email/health.svg)](https://phpackages.com/packages/bedeabza-bdz-html-email)
```

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M228](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M52](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

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

PHPackages © 2026

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