PHPackages                             vkr/external-email-bundle - 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. vkr/external-email-bundle

ActiveSymfony-bundle[Mail &amp; Notifications](/categories/mail)

vkr/external-email-bundle
=========================

A bundle for Symfony2/3 that loads email contents from an external file. Includes wildcard parsing

1.0.3(9y ago)032MITPHPPHP &gt;=5.6

Since Jul 17Pushed 9y ago1 watchersCompare

[ Source](https://github.com/wladislavk/ExternalEmailBundle)[ Packagist](https://packagist.org/packages/vkr/external-email-bundle)[ Docs](https://github.com/wladislavk/ExternalEmailBundle)[ RSS](/packages/vkr-external-email-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

About
=====

[](#about)

This bundle, in its present state, can do two things. First, it fetches an external file (either from your system or from the internet) and sends it as an email message. Second, it can also replace any wildcard that is included in that file into any value you want. The rules for wildcard parsing can include any kind of PHP code.

Installation
============

[](#installation)

This bundle depends on Symfony and VKRSettingsBundle, see that bundle's docs for details of its installation.

You need to configure some settings.

*mailer\_from\_address* and *mailer\_from\_name* correspond to the name and address in email *From* header.

There are two more settings with arbitrary names, one for the external file location, and another for the email subject. You need to define a pair of these settings for every message you want to send using this bundle. File location settings can be either full system paths or URLs.

See VKRSettingsBundle documentation on how to configure settings.

Usage
=====

[](#usage)

Without wildcards
-----------------

[](#without-wildcards)

If you don't have any wildcards, the usage is trivial. Write this code in your controller:

```
$emailParser = $this->get('vkr_external_email.parser');
$message = $emailParser->parse('file_location_setting', 'email_subject_setting',
                               'receiver@address.com', []);
$mailer = $this->get('mailer');
$mailer->send($message);

```

With wildcards
--------------

[](#with-wildcards)

You can include an arbitrary number of wildcards to be parsed in your external file. If you choose to use them, you need to write some extra code.

### Wildcard names

[](#wildcard-names)

Wildcard names can include only alphanumeric uppercase ASCII characters and underscores and must begin with a letter. You need to include % signs before and after a wildcard: `%MY_WILDCARD%`

### Wildcard parsers

[](#wildcard-parsers)

For every wildcard you create, you need to write a parser class that defines how this wildcard will be transformed. A parser class is just a PHP class that must implement *VKR\\ExternalEmailBundle\\Interfaces\\EmailParserInterface* and define its *parse()* method.

The parser class name should conform to a convention: camel-cased wildcard name with 'Parser' appended to it. So, if your wildcard is called *MY\_WILDCARD*, your parser class should be called *MyWildcardParser*. There is no convention regarding namespaces for those classes.

Here is an example of a simple parser class:

```
class MyWildcardParser implements VKR\ExternalEmailBundle\Interfaces\EmailParserInterface
{
    public function parse($additionalArguments=[])
    {
        return 'foo';
    }
}

```

This code means that every instance of `%MY_WILDCARD%` in your external file will be converted to `foo`.

After defining your parser classes, you must bootstrap them. In order to do it, you must pass an array of parser class instances as the fourth argument to the *parse()* method.

```
$wildcardParsers = [
    new MyWildcardParser(),
    new SomeOtherWildcardParser(),
];
$message = $emailParser->parse('file_location_setting', 'email_subject_setting',
                               'receiver@address.com', $wildcardParsers);

```

It is recommended that you register all your parsers as Symfony services and instantiate them via *$this-&gt;get()*.

### Additional arguments

[](#additional-arguments)

You might want to pass arguments to your parser's *parse()* method. In order to do it, you can specify any number of additional arguments and pass them as a fifth argument.

```
$wildcardParsers = [
    new MyWildcardParser(),
];
$args = [
    'value' => 'bar',
];
$message = $emailParser->parse('file_location_setting', 'email_subject_setting',
                               'receiver@address.com', $wildcardParsers);

```

Then, in your parser:

```
    public function parse($additionalArguments=[])
    {
        if (isset($additionalArguments['value'])) {
            return $additionalArguments['value'];
        }
        return 'foo';
    }

```

Now `%MY_WILDCARD%` will be changed to 'bar' rather than 'foo'.

An important thing to note is that if you have several parsers, all arguments will be passed to every parser. To avoid unexpected behavior, use unique argument names for every parser you have.

API
===

[](#api)

*void ExternalEmailParser::\_\_construct(VKR\\SettingsBundle\\Services\\SettingsRetriever $settingsRetriever)*

*Swift\_Message ExternalEmailParser::parse(string $emailFileSettingName, string $emailSubjectSettingName, string $receiverAddress, VKR\\ExternalEmailBundle\\Interfaces\\EmailParserInterface\[\] $wildcardParsers, array $additionalArguments=\[\])*

The fourth argument cannot be empty, if you don't have any parsers, pass empty array.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Total

4

Last Release

3339d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79f5fa971e7fda7a6180c1bdfca4f819a43b7681ec4e04c66b184a082fb5a20f?d=identicon)[wladislavk](/maintainers/wladislavk)

---

Top Contributors

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

---

Tags

emailSymfony2symfony3wildcards

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vkr-external-email-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/vkr-external-email-bundle/health.svg)](https://phpackages.com/packages/vkr-external-email-bundle)
```

###  Alternatives

[egulias/email-validator

A library for validating emails against several RFCs

11.6k691.3M307](/packages/egulias-email-validator)[sendgrid/sendgrid

This library allows you to quickly and easily send emails through Twilio SendGrid using PHP.

1.5k47.5M164](/packages/sendgrid-sendgrid)[pelago/emogrifier

Converts CSS styles into inline style attributes in your HTML code

94944.1M110](/packages/pelago-emogrifier)[zbateson/mail-mime-parser

MIME email message parser

53949.2M79](/packages/zbateson-mail-mime-parser)[soundasleep/html2text

A PHP script to convert HTML into a plain text format

48419.5M75](/packages/soundasleep-html2text)[opcodesio/mail-parser

Parse emails without the mailparse extension

216.8M8](/packages/opcodesio-mail-parser)

PHPackages © 2026

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