PHPackages                             sandstorm/templatemailer - 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. sandstorm/templatemailer

ActiveNeos-package[Mail &amp; Notifications](/categories/mail)

sandstorm/templatemailer
========================

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

3.0.1(1mo ago)1149.2k↓17.9%15[1 issues](https://github.com/sandstorm/TemplateMailer/issues)[2 PRs](https://github.com/sandstorm/TemplateMailer/pulls)2MITPHPCI passing

Since Mar 17Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/sandstorm/TemplateMailer)[ Packagist](https://packagist.org/packages/sandstorm/templatemailer)[ Docs](https://github.com/sandstorm/TemplateMailer)[ RSS](/packages/sandstorm-templatemailer/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (8)Versions (22)Used By (2)

Sandstorm.TemplateMailer - Simple Template-Based Emails for Neos and Flow
=========================================================================

[](#sandstormtemplatemailer---simple-template-based-emails-for-neos-and-flow)

Features
--------

[](#features)

This package works in Neos CMS and Flow and provides the following functionality:

- Simple creation and sending of Fluid template-based emails
- Automatic inlining of CSS into the email body, making it look good in clients like Gmail as well

Compatibility and Maintenance
-----------------------------

[](#compatibility-and-maintenance)

Sandstorm.TemplateMailer is currently being maintained for the following versions:

Neos / Flow VersionSandstorm.TemplateMailer VersionMaintainedFlow 9.x&gt;=2.4YesFlow 8.x2.xYesFlow 6.x, Flow 7.x2.xYesNeos 4.x, Flow 5.x1.xYesNeos 3.x, Flow 4.x1.xYesConfiguration and Usage
=======================

[](#configuration-and-usage)

Configuring Symfonymailer
-------------------------

[](#configuring-symfonymailer)

The TemplateMailer package requires SymfonyMailer to send out e-mails. Please check the SymfonyMailers package's configuration options () in order to configure SMTP credentials.

Configuring the package
-----------------------

[](#configuring-the-package)

This package provides 2 config options.

### Configuring global sender addresses

[](#configuring-global-sender-addresses)

By adding entries to the `senderAddresses` config array, you can define sender addresses in your config and connect them to a string identifier. This allows for easy global maintenance of email sender addresses and names. Override the "default" entry to just have one global sender address that's automatically used everywhere without you having to do anything else.

```
Sandstorm:
  TemplateMailer:
    senderAddresses:
      yourGlobalSender:
        name: 'Foo Bar'
        address: 'baz@example.com'
```

### Configuring global reply to addresses

[](#configuring-global-reply-to-addresses)

By adding entries to the `replyToAddresses` config array, you can define reply to addresses in your config and connect them to a string identifier. This allows for easy global maintenance of email reply to addresses and names. By default, no reply to address is used. To set a reply to address on the mail, you need to specify the reply to address key as method argument of `sendTemplateEmail`.

```
Sandstorm:
  TemplateMailer:
    replyToAddresses:
      yourGlobalReplyTo:
        name: 'Foo Bar'
        address: 'baz@example.com'
```

### Configuring template source packages

[](#configuring-template-source-packages)

You need to tell TemplateMailer in which packages it should look for email templates. Do this by adding an entry to the `templatePackages` array, like so:

```
Sandstorm:
  TemplateMailer:
    templatePackages:
      10: 'Your.Package'
```

If you have multiple packages that contain email templates, add them all in the order you want TemplateMailer to search them for templates. Lower numbers as keys mean that this package is checked earlier. If a template with the given name is found in a package, it is used. This way, you can create an override hierarchy.

### Default Template Variables

[](#default-template-variables)

You can expose configuration settings as default template variables to all email templates. We use this to expose the base Uri by default, but you can pass arbitrary settings paths here and they will be resolved.

```
Sandstorm:
  TemplateMailer:
    defaultTemplateVariables:
      baseUri: 'Neos.Flow.http.baseUri'
```

### Logging errors and sent mails

[](#logging-errors-and-sent-mails)

You can control how TemplateMailer handles errors and also successfully sent mails via the two parameters in `logging`. Via the "sendingErrors" config option, you can specifiy what templateMailer should do if the email could not be sent correctly. There are three options:

- 'throw' -&gt; throws the exception which came from SymfonyMailer if sending failed
- 'log' -&gt; logs a message to the system log if sending failed
- 'none' -&gt; silently swallow errors without logging or throwing them

For "sendingSuccess", you can only select 'log' or 'none'. 'log' will insert a log entry for all sent emails. Since this can create lots of entries in your log file, use it for debugging/monitoring purposes only.

```
Sandstorm:
  TemplateMailer:
    logging:
      sendingErrors: 'log'
      sendingSuccess: 'log'
```

Using the package
-----------------

[](#using-the-package)

Create an "EmailTemplates" folder in your package's `Resources/Private` folder. In it, create as many email templates as you want.

***IMPORTANT:*** You *must* create a .txt and an .html file with the same name for each template-based mail you want to send.

You can use partials and layouts as usual in Fluid. If you do, put them in `Resources/Private/EmailTemplates/Partials`or `Resources/Private/EmailTemplates/Layouts` respectively.

### Basic usage

[](#basic-usage)

A very basic usage without variables looks like this. Your template must not contain any variables (as you aren't passing in any) and TemplateMailer will use the "default" sender address, which you should configure beforehand.

```
$this->emailService->sendTemplateEmail(
    'YourTemplateFileName',
    'An arbitrary email title',
    ['recipient@example.com']
);
```

### Globally configured custom sender address

[](#globally-configured-custom-sender-address)

You can use a different configured sender address as well as pass variables to the template. You need to have configured the sender email 'mysender' before.

```
$this->emailService->sendTemplateEmail(
    'YourTemplateFileName',
    'An arbitrary email title',
    ['recipient@example.com'],
    [
        'var1' => 'Foo',
        'var2' => 5
    ],
    'mysender'
);
```

### Dynamic sender address

[](#dynamic-sender-address)

If you pass an array to the `sendTemplateEmail()` method, we'll pass it right through to SymfonyMailer so you can use sender email addresses that haven't been configured before.

```
$this->emailService->sendTemplateEmail(
    'YourTemplateFileName',
    'An arbitrary email title',
    ['recipient@example.com'],
    [
        'var1' => 'Foo',
        'var2' => 5
    ],
    ['sender@example.com' => 'Your Service Name']
);
```

### CC, BCC and Attachments

[](#cc-bcc-and-attachments)

You can also set cc, bcc and attachments. Here is a full example:

```
$this->emailService->sendTemplateEmail(
    'YourTemplateFileName',
    'An arbitrary email title',
    ['recipient@example.com'],
    [
        'var1' => 'Foo',
        'var2' => 5
    ],
    'mysender',
    ['cc@example.com', 'cc2@example.com'],
    ['bcc@example.com'],
    [
        [
            'data' => file_get_contents('some/example/file'),
            'filename' => 'YourFileNAme.pdf',
            'contentType' => 'application/pdf'
        ]
    ]
);
```

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance89

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community27

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

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

Recently: every ~379 days

Total

18

Last Release

43d ago

Major Versions

1.3.0 → 2.0.02019-11-04

2.4.0 → 3.0.02025-12-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ced0d63cfdae881c32128c7f66451a013d3e24d9eed210d6a846b6d8e95fa3b?d=identicon)[sandstorm](/maintainers/sandstorm)

---

Top Contributors

[![skurfuerst](https://avatars.githubusercontent.com/u/190777?v=4)](https://github.com/skurfuerst "skurfuerst (11 commits)")[![JamesAlias](https://avatars.githubusercontent.com/u/1615332?v=4)](https://github.com/JamesAlias "JamesAlias (5 commits)")[![daniellienert](https://avatars.githubusercontent.com/u/642226?v=4)](https://github.com/daniellienert "daniellienert (4 commits)")[![on3iro](https://avatars.githubusercontent.com/u/8681413?v=4)](https://github.com/on3iro "on3iro (2 commits)")[![finjaadam](https://avatars.githubusercontent.com/u/165460369?v=4)](https://github.com/finjaadam "finjaadam (1 commits)")[![htuscher](https://avatars.githubusercontent.com/u/5076356?v=4)](https://github.com/htuscher "htuscher (1 commits)")[![kdambekalns](https://avatars.githubusercontent.com/u/95873?v=4)](https://github.com/kdambekalns "kdambekalns (1 commits)")[![kitsunet](https://avatars.githubusercontent.com/u/324408?v=4)](https://github.com/kitsunet "kitsunet (1 commits)")[![Kleisli](https://avatars.githubusercontent.com/u/18674199?v=4)](https://github.com/Kleisli "Kleisli (1 commits)")[![sebastiansommer](https://avatars.githubusercontent.com/u/1651774?v=4)](https://github.com/sebastiansommer "sebastiansommer (1 commits)")[![beheist](https://avatars.githubusercontent.com/u/10347669?v=4)](https://github.com/beheist "beheist (1 commits)")[![tobiasgruber](https://avatars.githubusercontent.com/u/15209886?v=4)](https://github.com/tobiasgruber "tobiasgruber (1 commits)")[![dimitriadisg](https://avatars.githubusercontent.com/u/14919500?v=4)](https://github.com/dimitriadisg "dimitriadisg (1 commits)")[![erickloss](https://avatars.githubusercontent.com/u/16836464?v=4)](https://github.com/erickloss "erickloss (1 commits)")[![erkenes](https://avatars.githubusercontent.com/u/8766722?v=4)](https://github.com/erkenes "erkenes (1 commits)")

---

Tags

hacktoberfestcssmailemailmailerflowNeosmail template

### Embed Badge

![Health badge](/badges/sandstorm-templatemailer/health.svg)

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

###  Alternatives

[neos/neos

An open source Content Application Platform based on Flow. A set of core Content Management features is resting within a larger context that allows you to build a perfectly customized experience for your users.

1151.0M838](/packages/neos-neos)[neos/media

The Media package

101.2M57](/packages/neos-media)[voku/bounce-mail-handler

Bounce Mail Handler

50251.1k2](/packages/voku-bounce-mail-handler)[boundstate/yii2-mailgun

Mailgun integration for the Yii framework

28170.7k](/packages/boundstate-yii2-mailgun)[yarcode/yii2-mailgun-mailer

Mailgun mailer implementation for Yii2

1576.8k](/packages/yarcode-yii2-mailgun-mailer)

PHPackages © 2026

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