Skip to content

25th-floor/zf2-exception-mailer-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZendFramework 2 Exception Mailer Module

A simple ZF2 Module for sending Mails if Exceptions happen on production systems. In it's simplest configuration it just sends the stack trace of the Exception. But you can also render views and send html mails instead.

Installation

Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.

php composer.phar require 25th/zf2-exception-mailer-module
# (When asked for a version, type `0.*`)

Then add ExceptionMailer to your config/application.config.php.

Installation without composer is not officially supported and requires you to manually install all dependencies that are listed in composer.json

Configuration

To configure the Mailer use your application config:

<?php
return array(
	// Exception Stuff
	'exception_mailer' => array(
		// Mail
		'send' => true,
		'sender' => '[email protected]',
		'recipients' => array(
			'[email protected]',
		),
		'subject' => 'My Exception Mailer',
		'exceptionInSubject' => false

		// HTML Templates
		'useTemplate' => false,
		'template' => 'error/index'
	),
);

Ignore Exceptions

It's also possible to ignore certain Exceptions. Just let them implement the IgnoreExceptionInterface and they will be ignored.

HTML Emails

For HTML Emails set useTemplate to true and use the template parameter for your template configuration.

If you want to use a different template f.e. "error/mail" you also have to define it in the view_manager => template_map array with the correct position to it

<?php
return array(
	...
	'view_manager' => array(
		'template_map'        => array(
			...
			'error/mail'              => __DIR__ . '/../view/error/mail.phtml', // Exception_Mailer
			...
		),
	),
	...
);