Developed with love by KnpLabs Hire us for your project!
31

PostmarkBundle

by miguel250

Symfony2 postmark api bundle

PostmarkBundle

Symfony2 bundle for Postmark API Build Status

Setup

Using Composer
Add PostmarkBundle in your composer.json:

{
    "require": {
        "mlpz/postmark-bundle": "*"
    }
}
$ php composer.phar update mlpz/postmark-bundle

Using Submodule

git submodule add https://github.com/miguel250/PostmarkBundle.git vendor/bundles/MZ/PostmarkBundle
git submodule add https://github.com/kriswallsmith/Buzz.git  vendor/buzz

Add the MZ namespace to autoloader
You can skip this when using Composer

<?php
   // app/autoload.php
   $loader->registerNamespaces(array(
    // ...
    'MZ'               => __DIR__.'/../vendor/bundles',
    'Buzz'             => __DIR__.'/../vendor/buzz/lib',
  ));

Add PostmarkBundle to your application kernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new MZ\PostmarkBundle\MZPostmarkBundle(),
    );
}

Enable Postmark in config.yml
yml
mz_postmark:
api_key: API KEY
from_email: info@my-app.com
from_name: My App, Inc
use_ssl: true
timeout: 5

Usage

Message Service
``` php
<?php
$message = $this->get('postmark.message');
$message->addTo('test@gmail.com', 'Test Test');
$message->setSubject('subject');
$message->setHTMLMessage('email body');
$message->addAttachment(new Symfony\Component\HttpFoundation\File\File(FILE));
$response = $message->send();

$message->addTo('test2@gmail.com', 'Test2 Test');
$message->setSubject('subject2');
$message->setHTMLMessage('email body');
$message->addAttachment(new Symfony\Component\HttpFoundation\File\File(FILE), 'usethisfilename.php', 'text/plain');
$response = $message->send();
?>
```

Sending in batch
``` php
<?php
$message = $this->get('postmark.message');
$message->addTo('test@gmail.com', 'Test Test');
$message->setSubject('subject');
$message->setHTMLMessage('email body');
$message->queue(); // Queue the message instead of sending it directly

$message->addTo('test2@gmail.com', 'Test2 Test');
$message->setSubject('subject2');
$message->setHTMLMessage('email body');
$responses = $message->send(); // Send both messages, note that you'll get an array of json responses instead of just the json response
?>
```

Copyright (c) 2012 Miguel Perez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
mz_postmark:
api_key: ~ # Required
from_email: ~ # Required
from_name: true
use_ssl: true
timeout: 5
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago
  • Merge pull request #21 from wrep/feature/chunked-send
    By miguel250, 1 month ago