2017 © Pedro Peláez
 

symfony-bundle zeta-webmail-bundle

Symfony2 Send and Recibe Mail

image

tito/zeta-webmail-bundle

Symfony2 Send and Recibe Mail

  • Tuesday, May 20, 2014
  • by TiiToo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 68 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 13 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

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., (*1)

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

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., (*3)

Features

  • 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)

Installation

Install Zeta Components, (*4)

Currently this has still to be done through the old ezcomponents.org PEAR channel:, (*5)

pear channel-discover components.ez.no
pear install -a ezc/eZComponents

Add the following lines to your autoload.php:, (*6)

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

Add following lines to your composer.json file:, (*7)

"require": {, (*8)

...
"tito/zeta-webmail-bundle": "dev-master"

}, (*9)

Register Autoloading namespace SimpleThings into app/autoload.php, (*10)

Add Bundle to app/AppKernel.php, (*11)

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

Configure bundle in app/config.yml, (*12)

simple_things_zeta_webmail:
  security: admin_party
  list_layout: SimpleThingsZetaWebmailBundle::standalone.html.twig
  sources:
    gmail:
      type: imap
      host: imap.gmail.com
      username: xxx@gmail.com
      password: s3cr3t
      ssl: true
    other:
      type: pop
      host: pop.foo.de
      username: user
      password: s3cr3t
      ssl: true

You can also add the following routing files for the mailing viewer and the composer:, (*13)

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

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

Loaders

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:, (*14)

simple_things_zeta_webmail:
  security: admin_party
  sources:
    test:
      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., (*15)

Security

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:, (*16)

  • 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., (*17)

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., (*18)

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:, (*19)

  • 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., (*20)

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., (*21)

Sending

To send mails you have to configure the transport to send with:, (*22)

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

You can access this service by accessing:, (*23)

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

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

The following transports are shipped:, (*24)

  • 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., (*25)

Just put the following in your app/config/config.yml to get rid of Swiftmailer:, (*26)

fos_user:
  # ...
  service:
    mailer: simplethings.zetawebmail.fosuser.mailer

This service uses the transport service defined before for sending mails., (*27)

TODO

  • 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)

The Versions

20/05 2014

dev-master

9999999-dev https://github.com/TiiToo/ZetaWebmailBundle

Symfony2 Send and Recibe Mail

  Sources   Download

MIT

by Tito

mail webmail zeta