Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

dp-opensource/PostmarkBundle

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostmarkBundle

Symfony2 bundle for Postmark API

Using submodules

    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

Using deps file

[postmark]
    git=git://github.com/miguel250/postmark-php.git
    target=/Postmark

[PostmarkBundle]
    git=git://github.com/digitalpioneers/PostmarkBundle.git
    target=/bundles/Postmarkapp/PostmarkBundle

Add PostmarkBundle to your application kernel

<?php
// app/AppKernel.php
    public function registerBundles()
    {
       return array(
          // ...
          new Postmarkapp\PostmarkBundle\PostmarkappPostmarkBundle(),
          // ...
          );
     }

Add the Postmarkapp namespace to your autoloader

<?php
   // app/autoload.php
   $loader->registerNamespaces(array(
    // ...
    'Postmark'      => __DIR__.'/../vendor',
    'Postmarkapp'      => __DIR__.'/../vendor/bundles',
    // ...
  ));

Yml configuration

# app/config/config.yml
#postmark bundle
postmarkapp_postmark:
  apikey:          #Postmark api key
  from_address:    #Sender email
  from_name:       #Sender name[optional]

xml configuration

# 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"/>

Usage example:

<?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

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%