<commit_before>E-mail module for Zend Framework 2
==================================

[![Build Status](https://travis-ci.org/mtymek/MtMail.png?branch=master)](https://travis-ci.org/mtymek/MtMail)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mtymek/MtMail/badges/quality-score.png?s=f03d22161755c845d0ce06ab90a67cf4e3e340e0)](https://scrutinizer-ci.com/g/mtymek/MtMail/)
[![Code Coverage](https://scrutinizer-ci.com/g/mtymek/MtMail/badges/coverage.png?s=d4b2ac636d43b3dd8042675dd32ac8fe2cf4e390)](https://scrutinizer-ci.com/g/mtymek/MtMail/)
[![Latest Stable Version](https://poser.pugx.org/mtymek/mt-mail/v/stable.png)](https://packagist.org/packages/mtymek/mt-mail)
[![Total Downloads](https://poser.pugx.org/mtymek/mt-mail/downloads.png)](https://packagist.org/packages/mtymek/mt-mail)

Introduction
------------
MtMail handles common activities surrounding sending e-mail from applications, mainly creating messages
from templates, and sending them through transport adapters.

### Features:
* factory for creating e-mail messages
* factory for e-mail transport adapters, service for one-line dispatch
* rendering templates from `phtml` files, using `Zend\View` and `PhpRenderer`
* rendering templates with layouts
* plugins for various common tasks: from setting default headers to generating plaintext version of HTML message
* plugin support via dedicated plugin managers

Installation
------------
Installation is supported via Composer:

1. Add `"mtymek/mt-mail":"1.1.*"` to your `composer.json` file and run `php composer.phar update`.
2. Add MtMail to your `config/application.config.php` file under the modules key.


Creating e-mails
----------------

### Configuration

By default MtMail doesn't require any extra configuration. By default it will use `Zend\View` to render
templates accessible by your application.

### Usage

Creating message from controller:

```php
$mailService = $this->getServiceLocator()->get(\MtMail\Service\Mail::class);

$headers = [
    'to' => '<EMAIL>',
    'from' => '<EMAIL>',
];
$variables = [
    'userName' => '<NAME>',
];
$message = $mailService->compose($headers, 'application/mail/welcome.phtml', $variables);
```

This snippet will create a message, compose it with `$headers` and HTML body
rendered from `welcome.phtml` template (injected with `$variables` array).


### Layouts<commit_msg>Update README file<commit_after>E-mail module for Zend Framework 2
==================================

[![Build Status](https://travis-ci.org/mtymek/MtMail.png?branch=master)](https://travis-ci.org/mtymek/MtMail)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mtymek/MtMail/badges/quality-score.png?s=f03d22161755c845d0ce06ab90a67cf4e3e340e0)](https://scrutinizer-ci.com/g/mtymek/MtMail/)
[![Code Coverage](https://scrutinizer-ci.com/g/mtymek/MtMail/badges/coverage.png?s=d4b2ac636d43b3dd8042675dd32ac8fe2cf4e390)](https://scrutinizer-ci.com/g/mtymek/MtMail/)
[![Latest Stable Version](https://poser.pugx.org/mtymek/mt-mail/v/stable.png)](https://packagist.org/packages/mtymek/mt-mail)
[![Total Downloads](https://poser.pugx.org/mtymek/mt-mail/downloads.png)](https://packagist.org/packages/mtymek/mt-mail)

Introduction
------------
MtMail handles common activities surrounding sending e-mail from applications, mainly creating messages
from templates, and sending them through transport adapters.

### Features:
* factory for creating e-mail messages
* factory for e-mail transport adapters, service for one-line dispatch
* rendering templates from `phtml` files, using `Zend\View` and `PhpRenderer`
* rendering templates with layouts
* plugins for various common tasks: from setting default headers to generating plaintext version of HTML message
* plugin support via dedicated plugin managers

Installation
------------
Installation is supported via Composer:

```bash
$ composer require mtymek/mt-mail
```


Creating e-mails
----------------

### Configuration

By default MtMail doesn't require any extra configuration. It will use `Zend\View` to render
templates accessible by your application.

### Usage

Creating message from controller:

```php
$mailService = $this->getServiceLocator()->get(\MtMail\Service\Mail::class);

$headers = [
    'to' => '<EMAIL>',
    'from' => '<EMAIL>',
];
$variables = [
    'userName' => '<NAME>',
];
$message = $mailService->compose($headers, 'application/mail/welcome.phtml', $variables);
```

This snippet will create a message, compose it with `$headers` and HTML body
rendered from `welcome.phtml` template (injected with `$variables` array).


### Layouts
{'fraction_non_alphanumeric': 0.16407788230146575, 'fraction_numerical': 0.022752133012469918, 'mean_word_length': 4.992136304062909, 'pattern_counts': {'":': 1, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 20, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3330073', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1474, 'n_words': 348}