PHP code example of adesigns / email-template-bundle
1. Go to this page and download the library: Download adesigns/email-template-bundle 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/ */
adesigns / email-template-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Sfk\EmailTemplateBundle\SfkEmailTemplateBundle(),
);
}
// ...
class UserController extends Controller {
public function registerAction() {
// ...
if ($form->isValid()) {
//.. some actions here
$formData = array(
'email' => '[email protected]',
'first_name' => 'John',
'last_name' => 'Doe',
);
$template = $this->get('sfk_email_template.loader')
->load('AcmeDemoBundle:Emails:user_registered.html.twig', $formData)
;
$message = \Swift_Message::newInstance()
->setSubject($template->getSubject())
->setFrom($template->getFrom())
->setBody($template->getBody(), 'text/html')
->setTo($formData['email'])
;
// send email
$this->get('mailer')->send($message);
}
}
}
bash
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.