PHPackages                             holzweg/base-mail-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. holzweg/base-mail-bundle

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

holzweg/base-mail-bundle
========================

This Bundle provides mail support for Symfony2 applications

02PHP

Since Aug 30Pushed 12y ago3 watchersCompare

[ Source](https://github.com/holzweg/ICBaseMailBundle)[ Packagist](https://packagist.org/packages/holzweg/base-mail-bundle)[ RSS](/packages/holzweg-base-mail-bundle/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

InstaClick Base Mail Bundle
===========================

[](#instaclick-base-mail-bundle)

[![Build Status](https://camo.githubusercontent.com/2c97eb1826e3ef1c1918394a9bb72eda6ae56bd442511fba1d6a85df58099e3c/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f696e737461636c69636b2f4943426173654d61696c42756e646c652e706e67)](http://travis-ci.org/instaclick/ICBaseMailBundle)

Introduction
------------

[](#introduction)

This bundle provides a lower level support for mail manipulation on Symfony2. It is supported to deal with composing, sending and dealing with bounced messages in an abstract API.

Installation
------------

[](#installation)

Installing this bundle can be done through these simple steps:

1. Add this bundle to your project as a composer dependency:

    ```
    // composer.json
    {
        // ...
        require: {
            // ...
            "instaclick/base-mail-bundle": "dev-master"
        }
    }
    ```
2. Add this bundle in your application kernel:

    ```
    // application/ApplicationKernel.php
    public function registerBundles()
    {
        // ...
        $bundles[] = new IC\Bundle\Base\MailBundle\ICBaseMailBundle();

        return $bundles;
    }
    ```

Configuring the bundle
----------------------

[](#configuring-the-bundle)

By default, any composed message contains a sender name and address. This simplifies the implementation time and cleaner code. You are allowed to change these values anytime, but if negative, you can globally configure this support.

To define the default sender name and address, do the following:

```
ic_base_mail:
    composer:
        default_sender:
            name:    "InstaClick Mail Delivery"
            address: "noreply@instaclick.com"

```

This bundle also comes with a bounced email handler. For any reasons, when dealing with delivery of messages to users' mailbox, you also need to handle possible failures that users may have done. The best example is mispelled email addresses. To configure the bounced email handler, configure the `mail_bounce` section in bundle's configuration:

```
ic_base_mail:
    mail_bounce:
        mailhost: "imap.gmail.com"
        port:     993
        username: "%mailer_gmail_username%"
        password: "%mailer_gmail_password%"
        service:  "imap"
        option:   "ssl"
        mailbox:  "INBOX"

```

Using available Services
------------------------

[](#using-available-services)

The purpose of this bundle is to simplify mail creation, sending and handling possible failures. These three sections derived into three services that can be used by any application that consumes this bundle.

### Composer Service

[](#composer-service)

Responsible to compose messages. Configured default sender automatically injects sender name and address to any message that gets created out of this service. The methods `setDefaultSenderName` and `setDefaultSenderAddress`provide an ability to modify the values at runtime if necessary. Apart from the before mentioned methods, this service only contains one method: `createMessage`; it initializes a new message to be prepared for sending.

```
$composerService = $this->getContainer()->get('ic_base_mail.service.composer');
$message         = $composerService->createMessage();
```

A message instance contains a lot of options that can be defined by consuming its API. By default, any message is configured to be a `text/html` message and the method `setContentType` provides an ability to modify this behavior.

The interface for Message API is the following one:

```
interface MessageInterface
{
    /**
     * Get the subject.
     *
     * @return string
     */
    public function getSubject();

    /**
     * Set the subject.
     *
     * @param string $subject
     */
    public function setSubject($subject);

    /**
     * Get the recipient.
     *
     * @return string
     */
    public function getRecipient();

    /**
     * Set the recipient.
     *
     * @param string $recipient
     */
    public function setRecipient($recipient);

    /**
     * Get the senderName.
     *
     * @return string
     */
    public function getSenderName();

    /**
     * Set the senderName.
     *
     * @param string $senderName
     */
    public function setSenderName($senderName);

    /**
     * Get the senderAddress.
     *
     * @return string
     */
    public function getSenderAddress();

    /**
     * Set the senderAddress.
     *
     * @param string $senderAddress
     */
    public function setSenderAddress($senderAddress);

    /**
     * Get the sender (as a composite value of name and address)
     *
     * @return array
     */
    public function getSender();

    /**
     * Get the replyTo address.
     *
     * @return array
     */
    public function getReplyTo();

    /**
     * Set the repylTo address.
     *
     * @param string $replyTo
     */
    public function setReplyTo($replyTo);

    /**
     * Get the returnPath.
     *
     * @return array
     */
    public function getReturnPath();

    /**
     * Set the returnPath.
     *
     * @param string $returnPath
     */
    public function setReturnPath($returnPath);

    /**
     * Get the templateName.
     *
     * @return string
     */
    public function getTemplateName();

    /**
     * Set the templateName.
     *
     * @param string $templateName
     */
    public function setTemplateName($templateName);

    /**
     * Get the parameterList.
     *
     * @return array
     */
    public function getParameterList();

    /**
     * Set the parameterList.
     *
     * @param array $parameterList
     */
    public function setParameterList(array $parameterList = array());

    /**
     * Get the contentType.
     *
     * @return string
     */
    public function getContentType();

    /**
     * Set the contentType.
     *
     * @param string $contentType
     */
    public function setContentType($contentType);

    /**
     * Check if this message is usable.
     *
     * @return boolean
     */
    public function isUsable();
}
```

### Sender Service

[](#sender-service)

After your message is composed, it is time to send it. Sender service provides this support by exposing a public method called `send`. This method returns a boolean value in case of successful delivery or failure. It does not take into consideration bounced mail, since this is an asynchronous action that must be implemented by a consumer of BounceMail Service.

```
// ...
$composerService = $this->getContainer()->get('ic_base_mail.service.composer');
$senderService   = $this->getContainer()->get('ic_base_mail.service.sender');

$message = $composerService->createMessage();

$message->setSubject('Email Delivery Service');
$message->setRecipient('user@domain.com');
$message->setTemplateName('ICCoreSiteBundle:EmailTemplates:welcome.html.twig');
$message->setParameterList(array('username' => 'Guilherme Blanco'));

$sentSuccessfully = $senderService->send($message);
```

### BounceMail Service

[](#bouncemail-service)

TBD

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.4% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b630c682458c034231bfefe64f9d750030628844fb56c1a7791c1cfc6108d1c?d=identicon)[holzweg](/maintainers/holzweg)

---

Top Contributors

[![robocoder](https://avatars.githubusercontent.com/u/922051?v=4)](https://github.com/robocoder "robocoder (19 commits)")[![guilhermeblanco](https://avatars.githubusercontent.com/u/208883?v=4)](https://github.com/guilhermeblanco "guilhermeblanco (3 commits)")

### Embed Badge

![Health badge](/badges/holzweg-base-mail-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/holzweg-base-mail-bundle/health.svg)](https://phpackages.com/packages/holzweg-base-mail-bundle)
```

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M227](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)

PHPackages © 2026

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