1. Go to this page and download the library: Download erwane/cakephp-libs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
erwane / cakephp-libs example snippets
use Ecl\Mailer\Mailer;
use Cake\ORM\Entity;
$mailer = new Mailer();
$mailer
->setAllowedVars(['USER_NAME'])
->setViewVars([
'user' => new Entity(['name' => 'User Name']),
])
->setEmailFormat('text')
->deliver('Hello {{USER_NAME}}');
namespace App\Mailer;
use Ecl\Mailer\Mailer;
class UserMailer extends Mailer
{
public function welcome($user)
{
$this
->setTo($user->email)
->setSubject(sprintf('Welcome %s', $user->name))
->setAllowedVars(['USER_NAME'])
->set(['user' => $user]);
}
}
// templates/email/html/welcome.php
<p>Hi {{USER_NAME}}</p>