PHPackages                             draw/post-office-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. draw/post-office-bundle

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

draw/post-office-bundle
=======================

0.7.59(4y ago)03.2kMITPHPPHP ^7.3CI failing

Since Apr 12Pushed 4y ago1 watchersCompare

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

READMEChangelogDependencies (7)Versions (86)Used By (0)

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 allow to delegate creation of email to a specific class.

It also allow 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\\Bundle\\PostOfficeBundle\\Email\\EmailWriterInterface**will be register 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 it's 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 a **Email** folder in which you will create all your email class and also your **writer** class that does implement the **Draw\\Bundle\\PostOfficeBundle\\Email\\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.

```
