imag / notifier-bundle
Notifier bundle for Symfony 2
Installs: 5 208
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.3
- symfony/symfony: >2.0
This package is auto-updated.
Last update: 2024-10-28 04:31:31 UTC
README
NotifierBundle implements the most essential and basic functionalities of Swift_Mailer. The best way, is to sent a Html mail with Twig templating engine. You can also add many attachments at the mail.
Contact
Nick: aways
IRC: irc.freenode.net - #sf-grenoble
Install
- Download with composer
- Enable
- Configure
- Use it
Download
Add NotifierBundle in your project's composer.json
{ "require": { "imag/notifier-bundle": "1.0.*@stable" } }
Enable
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new IMAG\NotifierBundle\IMAGNotifierBundle(), ); }
Configure
All next parameters are a default value.
#config.yml imag_notifier: default_from: fqdn@d.tld default_subject: Defaul subject subject_prefix: "[Application][Tag] " #Default ''(empty string)
Use it
Html mail
$notifier = $this->get('imag_notifier.provider'); $html = $notifier->createHtmlMessage(); $attach = $notifier->createAttachment(); $attach ->loadFile('/tmp/toto') ->setFilename('toto.txt') ->setMimeType('application/txt') ; $html->addAttachment($attach); $attach = $notifier->createAttachment(); $attach->setData('Your content'); $html->addAttachment($attach); $html ->addTo('foo@d.tld') ->addCc('foo@d.tld') ->setBcc(array( 'foo@d1.tld', )) ->addBcc('foo@d2.tld') ->setSubject('Foo') ->setTemplate('IMAGYourBundle:Mail:contact.html.twig', array( 'name' => 'toto', 'subject' => 'subject', 'date' => new \Datetime(), 'body' => 'body', )) ; $notifier->send($html);
Create basic mail
$notifier = $this->get('imag_notifier.provider'); $html = $notifier->createMessage();