PHPackages                             millsoft/htmlmailcompiler - 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. millsoft/htmlmailcompiler

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

millsoft/htmlmailcompiler
=========================

HTML Mail Compiler

1.1.2(6y ago)520PHP

Since Jan 1Pushed 2y agoCompare

[ Source](https://github.com/millsoft/htmlmailcompiler)[ Packagist](https://packagist.org/packages/millsoft/htmlmailcompiler)[ RSS](/packages/millsoft-htmlmailcompiler/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

[![HTML Mail Compiler](https://raw.githubusercontent.com/millsoft/htmlmailcompiler/master/example/src/img/htmlmailcompiler-logo.png)](https://raw.githubusercontent.com/millsoft/htmlmailcompiler/master/example/src/img/htmlmailcompiler-logo.png)

HTML Mail Compiler (hmc)
========================

[](#html-mail-compiler-hmc)

HTML Mail Compiler is a tool that will inject inline CSS styles into your html template and output compiled html as a file. It uses [emogrifier](https://github.com/jjriv/emogrifier) library for the merge process.

Motivation
----------

[](#motivation)

Creating HTML emails can be a nightmare. It works by using inline CSS inside HTML. Then if you need to change something you need to change all your inline CSS. With this script it will do the work for you. You have 2 files: your html template (a php file) and a css file. You can create CSS styles for classes, IDs or just HTML tags. This script will generate one or multiple HTML templates with inlined CSS for you automatically.

Requirements
------------

[](#requirements)

- PHP from 5.4 or better
- Composer

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

[](#installation)

`composer global require millsoft/htmlmailcompiler`

After the installation a new global command is available: `hmc` (= html mail compiler). Open your terminal and type it in your console to check if it works. If not, check if your global composer path is defined in your PATH envirnonment variable.

How to use it?
--------------

[](#how-to-use-it)

To create a HTML template you normally used to create a new HTML file and work on it. Now you create a PHP file with your usual stuff in it and put the `link` Tag to include your CSS file. You also need to put a `compile.json` file into your folder. In that file you specify how the tool should generate the final HTML template.

Please see the example folder for an example. The source files are stored in `example/src` and after generation your files are stored in `example/dist`

Example Usage
-------------

[](#example-usage)

Terminal: `hmc .`

This command will load `compile.json` file in the current directory and do whatever is specified in that file. You can also specify a different directory, eg.: `hmc ~/abc/def`

Configuration file
------------------

[](#configuration-file)

You need to create a `compile.json` file first (or look at the [example file](example/src/compile.json) ). Put it in your folder where you create your HTML E-Mail. The file can look like this:

keyvaluetemplate\_fileYour html template. Should be a php file, eg. "template.php" The file is a normal HTML file with linked CSS filecss\_fileName of your CSS file. eg. "style.css". This can be one or more files. Use array form when using multiple css filesstart\_nrStart the index from this number (default: 0)minifyMinify the html file (default: false)generatean array of files to generate. The index of the array will be passed in the generation process and is available in the $nr variableplaceholders(object) - You can use placeholders which will be replaced with the values in this file.output\_dirWhere should be the generated files be stored? eg. "../dist". If not specified, the source directory will be used as target directory.zip(object) settings for the ZIP file generation. Key "filename" is used for the output filename. Key "files" is an array of which additional files should be stored in the ZIP file. Local image assets will be automatically stored in the zip fileParameters
----------

[](#parameters)

Usually the only parameter you need is the path, eg `hmc .`.

There are also some additional parameters you can enter:
`--config=compile2.json` : Uses a different config file (default is compile.json)
`--path=another_path` : specify another directory where your files are.

Contributors
------------

[](#contributors)

You want to extend it? project is open for pull requests :)

License
-------

[](#license)

Open Source License.
Developed by MilMike // 29.11.2017 () Last Update: 02.08.2019

Further Reading
---------------

[](#further-reading)

More details about this project on my blog:

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

3

Last Release

2479d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d361f7320ad64490dfdffc028f14804235c6eeff6eef5066c156cf9a0c3a0732?d=identicon)[millsoft](/maintainers/millsoft)

---

Tags

cssemailemail-templatehtmlhtml-emailhtml-emailshtml-templateinline-cssphpinline-csshtmlcompilerhtmlmailhtmlemailhtmlmailcompilerhtml mail compilerhtml emailbulletproof html email

### Embed Badge

![Health badge](/badges/millsoft-htmlmailcompiler/health.svg)

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

###  Alternatives

[snowfire/beautymail

Send beautiful html emails with Laravel

1.3k733.1k2](/packages/snowfire-beautymail)[dachcom-digital/emailizr

Pimcore Emailizr - create html emails the right way!

17370.2k4](/packages/dachcom-digital-emailizr)[markguinn/silverstripe-email-helpers

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

3145.4k1](/packages/markguinn-silverstripe-email-helpers)[sandstorm/templatemailer

Neos and Flow package for simple handling of template-based emails, including CSS inlining

1147.3k2](/packages/sandstorm-templatemailer)[mediaessenz/mail

Powerful newsletter system for TYPO3

119.1k2](/packages/mediaessenz-mail)

PHPackages © 2026

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