PHPackages                             silktide/templated-emailer - 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. silktide/templated-emailer

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

silktide/templated-emailer
==========================

Templated emailer

0.1.1(10y ago)0231GPL-2.0+PHPPHP &gt;=5.5.0

Since Sep 10Pushed 8y ago3 watchersCompare

[ Source](https://github.com/silktide/templated-emailer)[ Packagist](https://packagist.org/packages/silktide/templated-emailer)[ RSS](/packages/silktide-templated-emailer/feed)WikiDiscussions master Synced 1mo ago

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

[![Build Status](https://camo.githubusercontent.com/bcdc34bb97902c9ceaa40714a05f81855d56310eee3e13ea696146c2fd9c31ab/68747470733a2f2f7472617669732d63692e6f72672f73696c6b746964652f74656d706c617465642d656d61696c65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/silktide/templated-emailer)[![Code Climate](https://camo.githubusercontent.com/e5192974a595b03c64dd46fb760ea87193adadc799c6e4efda94b631550fe3ae/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f73696c6b746964652f74656d706c617465642d656d61696c65722f6261646765732f6770612e737667)](https://codeclimate.com/github/silktide/templated-emailer)[![Test Coverage](https://camo.githubusercontent.com/d98e5498bc854861ee258b5304d2933a975401ff5d01d6c21fea1718d5aabf62/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f73696c6b746964652f74656d706c617465642d656d61696c65722f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/silktide/templated-emailer/coverage)

Templated emailer
=================

[](#templated-emailer)

This library simply ties together Symfony's powerful templating engine with the flexibility of Swiftmailer, allowing you to send templated emails easily.

Setup
-----

[](#setup)

### Without DI

[](#without-di)

If you're not using DI (or don't know what DI is) there is a helpful factory to create the mailer:

```
$emailer = \Silktide\TemplatedEmailer\TemplatedEmailerFactory::create('/path/to/templates');

```

The only required argument is the path to the folder containing your email templates (see Creating a template below).

By default, the factory will set up the class to use PHP's mail() function to send your mail and Symfony's PhpEngine for templating. You can optionally provide a [Swiftmailer transport class](http://swiftmailer.org/docs/sending.html) as the second argument if you want to use a different transport, e.g. SMTP. Here's an example of using an alternative transport:

```
$transport = \Swift_SmtpTransport::newInstance('smtp.example.org', 25)
            ->setUsername('your username')
            ->setPassword('your password');
$emailer =  \Silktide\TemplatedEmailer\TemplatedEmailerFactory::create('/example', $transport);

```

### Dependency injection / manual instantiation

[](#dependency-injection--manual-instantiation)

The TemplatedEmailer class just requires two arguments, a Symfony template engine and an instance of Swift\_Mailer:

```
/**
* @var \Symfony\Component\Templating\EngineInterface
*/
$templateEngine;

/**
* @var \Swift_Mailer
*/
$emailClient;

$emailer = new \Silktide\TemplatedEmailer\TemplatedEmailer($templateEngine, $emailClient);

```

Creating a template
-------------------

[](#creating-a-template)

Templates are using [Symfony's well documented template library](http://symfony.com/doc/current/components/templating/introduction.html). Here's a very basic example:

```
An email from myApp
Dear

```

The variables in the message are passed through as an array to the send() method (see usage below).

Usage
-----

[](#usage)

Before any emails can be sent, you must set a sender:

```
$emailer->setSender('pat@postman.com', 'Postman Pat');

```

Sending an email now just requires a recipient, subject, template filename and context:

```
$this->mailer->send(
    'mrsgoggins@greendalepo.com',
    'Jess the black and white cat',
    'anEmail.php',
    [
        'recipientName' => 'Mrs Goggins',
        'message' => 'Hello!'
    ]
);

```

The recipient can also have a name set by using an array in the format \['' =&gt; 'Friendly Name'\]:

```
$this->mailer->send(
    ['mrsgoggins@greendalepo.com' => 'Mrs Goggins'],
    'Jess the black and white cat',
    'anEmail.php',
    [
        'recipientName' => 'Mrs Goggins',
        'message' => 'Hello!'
    ]
);

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity49

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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3903d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/194d1fe23e2566b3c00d0edf69239351d6c7b442abb17c8e92f8f4d1b58945af?d=identicon)[Dolondro](/maintainers/Dolondro)

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

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

---

Top Contributors

[![andywaite](https://avatars.githubusercontent.com/u/6773151?v=4)](https://github.com/andywaite "andywaite (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/silktide-templated-emailer/health.svg)

```
[![Health](https://phpackages.com/badges/silktide-templated-emailer/health.svg)](https://phpackages.com/packages/silktide-templated-emailer)
```

###  Alternatives

[cspoo/swiftmailer-mailgun-bundle

Swiftmailer Mailgun bundle

1031.1M](/packages/cspoo-swiftmailer-mailgun-bundle)[wildbit/swiftmailer-postmark

A Swiftmailer Transport for Postmark.

542.8M6](/packages/wildbit-swiftmailer-postmark)[openbuildings/swiftmailer-css-inliner

Inline the css of your html emails

69401.9k3](/packages/openbuildings-swiftmailer-css-inliner)[mailjet/mailjet-swiftmailer

A SwiftMailer transport implementation for Mailjet

261.2M9](/packages/mailjet-mailjet-swiftmailer)[phalcon-ext/mailer

Mailer component as wrapper over SwiftMailer for Phalcon.

39196.9k2](/packages/phalcon-ext-mailer)[openbuildings/postmark

Swiftmailer Transport Class for Postmark

15369.8k2](/packages/openbuildings-postmark)

PHPackages © 2026

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