PHPackages                             draw/mailer - 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. draw/mailer

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

draw/mailer
===========

0.39.2(2mo ago)08.9k2MITPHPPHP &gt;=8.5

Since May 5Pushed 2mo ago1 watchersCompare

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

READMEChangelogDependencies (24)Versions (181)Used By (2)

DrawPostOfficeBundle
====================

[](#drawpostofficebundle)

**Be since the Symfony/Mailer is not completed yet some behavior may be affected in later release, consider this bundle as experimental too**

This bundle allows to delegate creation of email to a specific class.

It also allows configuration for a default **from**.

Configuration
-------------

[](#configuration)

```
draw_post_office:
  default_from: 'support@example.com'

```

Instead of building your email in your controller directly you create a class that extend from the **Symfony\\Component\\Mime\\Email** and create a **writer** for it.

Any service that implement the **Draw\\Component\\Mailer\\EmailWriter\\EmailWriterInterface**will be registered as a writer. The **getForEmails** must return a map of method with priority as the value to register method as a writer (if you return the method as the value it will consider is priority to be 0). The system will detect if the email match the class of the first argument of the method and call it if needed.

The Post Office declare a listener for **Symfony\\Component\\Mailer\\Event\\MessageEvent** to hook it to the symfony mailer.

By convention, it's recommend to create an **Email** folder in which you will create all your email class and also a **EmailWriter** for your class that does implement the **Draw\\Component\\Mailer\\EmailWriter\\EmailWriterInterface**.

Example
-------

[](#example)

Let's create a forgot password email, this class will contain the **minimum** information to compose the email, in that case the email of the user that trigger the forgot password email flow.

```
