Developed with love by KnpLabs Hire us for your project!


by simplethings

[DEPRECATED] Simple reusable webmailer for Symfony2 using Zeta Components Mail

Zeta Webmail Bundle

A flexible Mail bundle for Symfony2 for sending and displaying purposes
You can show mailbox contents and mails loaded from arbitrary sources. Zeta Components is used to parse mails and
access IMAP/POP sources, a simple interface is provided to allow any source of mails such as
a database or the filesystem.

Zeta Components sending and composing capabilities are also leveraged, a transporting service is provided,
making this bundle a dropin replacement for SwiftMailerBundle.

The transporting service is integrated into the WebDebugToolbar and shows the number of sent mail
per request and shows their headers. Zeta Webmail Bundle ships with a NullTransport that can be
used for sending in development.


  • Send mails using transport services (SwiftMailerBundle replacement)
  • Integration into WebDebugToolbar
  • Mailer for FOS\UserBundle (SwiftMailerBundle replacement)
  • List Mails from Imap/Pop accounts (pagination included)
  • Add arbitrary backend that provides mails.
  • Download mail as .eml to open with associated Outlook, Thunderbird or other mail clients.
  • View HTML, Text and Multipart Mails
  • HTML XSS Injection prevented by Washtml library
  • Privacy protected by not displaying images in html mails by default.
  • Security abstraction to configure access to mail sources and mailboxes.
  • Interactive Example using reusable jQuery plugin (list_layout: SimpleThingsZetaWebmailBundle::interactive.html.twig)


Install Zeta Components

Currently this has still to be done through the old PEAR channel:

pear channel-discover
pear install ezc/Mail

Add the following lines to your autoload.php:

require_once "ezc/Base/base.php";
spl_autoload_register(array("ezcBase", "autoload"));

Download this bundle into vendor/bundles/SimpleThings/ZetaWebmail:

git clone git:// vendor/bundles/SimpleThings/ZetaWebmail

Register Autoloading namespace SimpleThings into app/autoload.php

Add Bundle to app/AppKernel.php

public function registerBundles()
    $bundles = array(
        new SimpleThings\ZetaWebmail\SimpleThingsZetaWebmailBundle(),
    return $bundles;

Configure bundle in app/config.yml

  security: admin_party
  list_layout: SimpleThingsZetaWebmailBundle::standalone.html.twig
      type: imap
      password: s3cr3t
      ssl: true
      type: pop
      username: user
      password: s3cr3t
      ssl: true

You can also add the following routing files for the mailing viewer and the composer:

    resource: "@SimpleThingsZetaWebmailBundle/Resources/config/routing.yml"
    prefix: /zeta

    resource: "@SimpleThingsZetaWebmailBundle/Resources/config/routing_composer.yml"
    prefix: /zeta


To add your own source for mails implement SimpleThings\ZetaWebmail\Mailbox\Loader\MailboxLoader and
SimpleThings\ZetaWebmail\Mailbox. You can then register this loader by specifying its service-id
in the "type" key of your source:

  security: admin_party
      type: my.zetawebmail.loader.service

Be aware that the pagination in the Mailbox interface is based on message numbers, i.e. ascending
by date starting with message number 1 and ending with message number equaling the message count.


Access to mails

To protect mails from being read without proper access there is a very small abstraction layer for security
built into the Webmail bundle. By default there are two very simple security roles shipped with the bundle:

  • admin_party - Everybody is allowed to read all sources, mailboxes and mails.
  • zeta_mail_role - Only users with the role "ROLE_ZETAMAIL" can view all sources and their mailboxxes.

XSS Prevention (HTML-Mails)

This bundle uses washtml to sanitize HTML mail content before displaying.
Not the original code but an object-oriented modification written by Roundcube developers
is used for this task.

HTML Images

By default images are not displayed and replaced with an empty local image. A message box appears
on top of the mailing and allows users to decide to display the images or not.

Integrate into your Application

There are two routes that you can use to integrate either a list of mails or a view of a mail into
your application:

  • simplethings_zetawebmail_list_mail with parameters "source", "mailbox"
  • simplethings_zetawebmail_view_mail with parameters "source", "mailbox", "mail"

The view mail route should ALWAYS be contained into an iframe, since otherwise HTML mails will render themselves
into your application layout. I suggest using at least 600 width for the iframe, which a standard size
for preview windows.

The list view does not use a layout itself so you can use the {% render %} command from Twig to
display this as an widget where ever you please.


To send mails you have to configure the transport to send with:

        type: smtp
        host: localhost
        user: foo
        password: bar
        port: 1234

You can access this service by accessing:

$mail = new \ezcMailComposer();
// compose the mail here...

$transport = $container->get("simplethings.zetawebmail.transport");

The following transports are shipped:

  • smtp - SMTP Transport (ezcMailSmtpTransport)
  • mta - MTA Transport (ezcMailMtaTransport)
  • null - Send nothing (good for development). MUST BE PUT IN QUOTES

Using Zeta Components with FOS\UserBundle

The FOS\UserBundle has an abstraction layer for mails that are sent for confirmation and reset password
purposes. The ZetaWebmailBundle ships with a replacement of the default SwiftMailer implementation.

Just put the following in your app/config/config.yml to get rid of Swiftmailer:

  # ...
    mailer: simplethings.zetawebmail.fosuser.mailer

This service uses the transport service defined before for sending mails.


  • View source of mail action.
  • Make sorting of subject, from, to configurable for developers and for webmail users.
  • Add functionality for sorting of messages by criteria to mailbox interface.
  • Stream download of mails and attachments?
  • Add write support: Read Status, Marking as read/unread, delete, move between mailboxes in a source.
  • Allow to hook into operations on mails to allow application specific workflows (such as Add To address book)
  • Fix stylesheet with <pre> to wrap text.
    By beberlei, 8 years ago
  • UTF-8 Rendering Bugfix
    By beberlei, 9 years ago
  • Adjust ZetaMailer for FOS UserBundle to latest interface
    By beberlei, 9 years ago
  • Adjust to latest FOS User Bundle changes
    By beberlei, 9 years ago
  • Fix error when FOS UserBundle is not installed
    By beberlei, 9 years ago
  • Detect HTML mails for registration and password reset
    By beberlei, 9 years ago
  • UserBundle Service: Send Mails in UTF-8 always
    By beberlei, 9 years ago
  • Add FOS\UserBundle Mailer service that uses Zeta Components and is a replacement for the Swiftmailer implementation
    By beberlei, 9 years ago
  • Update README
    By beberlei, 9 years ago
  • Remove composer for now
    By beberlei, 9 years ago
  • Update README
    By beberlei, 9 years ago
  • Render body, this is necessary for debug aswell!
    By beberlei, 9 years ago
  • Add sending transport support, add logging and web-debug-toolbar support. First skeleton of composer.
    By beberlei, 9 years ago
  • Fix issue with ezcMail to having access to imap uids by passing sort and reverse flags around aswell.
    By beberlei, 9 years ago
  • Implement sorting on the interface/implementation level and make sort by date descending the default.
    By beberlei, 9 years ago
  • Add folder view for mailboxes, extended security model, fixed some small bugs.
    By beberlei, 9 years ago
  • Interactive Example, Mailbox Refactoring
    By beberlei, 9 years ago
  • Fix a bunch of bugs in displaying.
    By beberlei, 9 years ago
  • Add support to switch between html and text parts for multipart mails.
    By beberlei, 9 years ago
  • Modifications to README for rendering
    By beberlei, 9 years ago
  • Inital commit of ZetaWebmailBundle
    By beberlei, 9 years ago