Giter Site home page Giter Site logo

postmarkbundle's Introduction

PostmarkBundle

Symfony3 bundle for Postmark API Build Status

This is a ridiculously minor update of Miguel Perez's no-longer maintained code from https://github.com/miguel250/PostmarkBundle to allow for Symfony 3 compatibility. All credit/kudos/thanks for the work should obviously go to him

Setup

Using Composer Add PostmarkBundle in your composer.json:

{
    "require": {
        "stephenfarrell/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

mz_postmark:
    api_key: API KEY
    from_email: [email protected]
    from_name: My App, Inc
    use_ssl: true
    timeout: 5

Usage

Message Service

<?php
$message  = $this->get('postmark.message');
$message->addTo('[email protected]', 'Test Test');
$message->setSubject('subject');
$message->setHTMLMessage('<b>email body</b>');
$message->addAttachment(new Symfony\Component\HttpFoundation\File\File(__FILE__));
$response = $message->send();

$message->addTo('[email protected]', 'Test2 Test');
$message->setSubject('subject2');
$message->setHTMLMessage('<b>email body</b>');
$message->addAttachment(new Symfony\Component\HttpFoundation\File\File(__FILE__), 'usethisfilename.php', 'text/plain');
$response = $message->send();
?>

Sending in batch

<?php
$message  = $this->get('postmark.message');
$message->addTo('[email protected]', 'Test Test');
$message->setSubject('subject');
$message->setHTMLMessage('<b>email body</b>');
$message->queue(); // Queue the message instead of sending it directly

$message->addTo('[email protected]', 'Test2 Test');
$message->setSubject('subject2');
$message->setHTMLMessage('<b>email body</b>');
$responses = $message->send(); // Send both messages, note that you'll get an array of json responses instead of just the json response
?>

postmarkbundle's People

Contributors

miguel250 avatar ruudk avatar mac-cain13 avatar stephenfarrell avatar hugomn avatar olemchls avatar rickpastoor avatar

Watchers

James Cloos avatar  avatar

Forkers

webignition

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.