Sending email by lithium php

I choose nice library li3_mailer delivered by @eLod for my #li3 app and sending email by gmail smtp server. Lets do it.

in console, check your libraries paths..

git submodule add libraries/li3_mailer;
git submodule add libraries/swiftmailer
git submodule init
git submodule update

attach added libraries to app/config/bootstrap/libraries.php in `add some plugins section`

Libraries::add('swiftmailer', array('prefix' => 'Swift_', 'bootstrap' => 'lib/swift_required.php'));

in connection.php (i think is good place)

use li3_mailer\net\mail\Delivery;

Delivery::config(array('default' => array(
'adapter' => 'Swift',
'transport' => 'smtp',
'from' => array('' => ''),
'username' => '', #its for business accounts config otherwise use
'password' => 'googleuserpassword',
'host' => '',
'port' => 465,
'encryption' => 'ssl'

prepare templates and views for html and text email in files /app/mails/layouts/default.{html,text}.php with

< ?php echo $this->content(); ?>
Big rgd. !


User data:
< ?php print_r($User); ?>

now its time to sending email put this code to the action in Controller

//use li3_mailer\action\Mailer;
//$User = Users::first...
$success = Mailer::deliver('news', ['to' => $email, 'subject' => 'news subject', 'data' => compact('User')]); //@return 1 if ok

thats all 🙂 mails templates should be working with g11n translation

glory area
– thanx for advice @rapzo