dev-master
9999999-dev https://github.com/vikey89/EmailZF2EmailZF2 is a ZF2 module to manage the process of sending emails with templates.
BSD-3-Clause
The Requires
- php >=5.3.3
- zendframework/zendframework 2.*
send email email zf2 module zf2
EmailZF2 is a ZF2 module to manage the process of sending emails with templates.
Version 1.1, (*2)
Module which allows sending emails in Zend Framework 2 with or without template., (*3)
For the installation use composer composer., (*4)
php composer.phar require email-zf2/emailzf2:dev-master
If you have installed composer:, (*5)
composer require email-zf2/emailzf2:dev-master
Once the installation with composer pass to the configuration., (*6)
config/application.config.php
under array modules
, insert EmailZF2
email.local.php
under config/autoload/
. <?php return array( 'email' => array( 'credentials' => array( 'from_mail' => 'support@domain.com', 'from_name' => 'yourname', ), //use smtp or sendmail 'transport' => 'sendmail', 'smtp' => array( 'host' => 'smtp.domain.com', 'port' => 587, 'connection_class' => 'login', 'connection_config' => array( 'ssl' => 'tls', 'username' => 'youremail', 'password' => 'yourpassword' ), ), ), );
In this way we have just created our configuration file. In this file we can choose whether to send emails with sendmail installed on the server or send email using smtp. If you want to leave the sendmail configuration file so as it is., (*7)
Just create any module in a folder to save the template to use for emails. By convention we put the folder in the Application Module.
- create a folder emails
under Application/view/
.
- create a template hello_world.phtml
.
- Come in any Controller and ship our test message, in this case for test use IndexController
under module Application
., (*8)
$view = new ViewModel(array( 'fullname' => 'Vincenzo Provenza', )); $view->setTerminal(true); $view->setTemplate('Application/view/emails/hello_world'); $this->mailerZF2()->send(array( 'to' => 'email@domain.it', 'subject' => 'This is subject' ), $view);
$view = new ViewModel(array( 'fullname' => 'Vincenzo Provenza', )); $view->setTerminal(true); $view->setTemplate('Application/view/emails/hello_world'); $this->mailerZF2()->send(array( 'to' => 'email@domain.com', 'cc' => 'email2@domain.com', 'subject' => 'This is subject' ), $view);
$view = new ViewModel(array( 'fullname' => 'Vincenzo Provenza', )); $view->setTerminal(true); $view->setTemplate('Application/view/emails/hello_world'); $this->mailerZF2()->send(array( 'to' => 'email@domain.com', 'cc' => 'email2@domain.com', 'bcc' => 'email3@domain.com', 'subject' => 'This is subject' ), $view);
$view = new ViewModel(array( 'fullname' => 'Vincenzo Provenza', )); $view->setTerminal(true); $view->setTemplate('Application/view/emails/hello_world'); $this->mailerZF2()->send(array( 'to' => 'email@domain.com', 'replyTo' => 'mariorossi@domain.com', 'replyNameTo' => 'Mario Rossi', 'subject' => 'This is subject' ), $view);
<h4>Hi, <?= $fullname; ?></h4>
EmailZF2 is a ZF2 module to manage the process of sending emails with templates.
BSD-3-Clause
send email email zf2 module zf2