Symfony2 bundle for Postmark API
git submodule add https://github.com/miguel250/PostmarkBundle.git vendor/bundles/Postmarkapp/PostmarkBundle
git submodule add https://github.com/miguel250/postmark-php.git vendor/Postmark
[postmark]
git=git://github.com/miguel250/postmark-php.git
target=/Postmark
[PostmarkBundle]
git=git://github.com/digitalpioneers/PostmarkBundle.git
target=/bundles/Postmarkapp/PostmarkBundle
<?php
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Postmarkapp\PostmarkBundle\PostmarkappPostmarkBundle(),
// ...
);
}
<?php
// app/autoload.php
$loader->registerNamespaces(array(
// ...
'Postmark' => __DIR__.'/../vendor',
'Postmarkapp' => __DIR__.'/../vendor/bundles',
// ...
));
# app/config/config.yml
#postmark bundle
postmarkapp_postmark:
apikey: #Postmark api key
from_address: #Sender email
from_name: #Sender name[optional]
# app/config/config.xml
# add namespace to <container> tag
xmlns:postmark="http://symfony.com/schema/dic/postmarkapp_postmark"
# add postmark config inside <container> tag
<postmark:config apikey="xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" from-address="your@email.com" from-name="optional"/>
<?php
$message = $this->get('postmark')->compose();
$message->addTo('user@email.com', 'user name');
$message->subject('subject');
$message->messagePlain('email body');
$message->send();
$secondMessage = $this->get('postmark')->compose();
$secondMessage->addTo('user@email.com', 'user name');
$secondMessage->subject('subject');
$secondMessage->messagePlain('email body');
$secondMessage->send();
note: This bundle is using postmark-php class slightly modified to implemented namespaces