承接 ffreitas-br/mandrill-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ffreitas-br/mandrill-bundle

最新稳定版本:v2.0.0

Composer 安装命令:

composer require ffreitas-br/mandrill-bundle

包简介

Symfony MandrillBundle

README 文档

README

Build Status

Send transactional mail through mandrill.com. This bundle provides an easy api for Symfony2 Projects.

All settings inside message class represent attributes of Mandrill's API. Please refer to their API documentation for Details:

https://mandrillapp.com/api/docs/messages.html

Prerequisites

Before you're able to use this bundle you must sign up with Mandrill.

http://mandrill.com

Mandrill is a great way to send your transactional emails and provides detailed advances reports.

Mandrill is free for limited number of email per day, please read through pricing section on the website for more information:

http://mandrill.com/pricing/

Installation

Add the bundle to your composer.json

# composer.json
{
 "require": {
     "ffreitas-br/mandrill-bundle": "1.*",
 }
}

Run composer install

php ./composer.phar install

Enable the bundle in the kernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new FFreitasBr\MandrillBundle\MandrillBundle(),
    );
}

Configuration

Add configuration to config.yml.

Log in to Mandrill and go to "Settings" -> "SMTP and API Credentials". Create an API Key and use it in your Symfony2 Configuration.

# config.yml

mandrill:
    api_key: xxxxx
    disable_delivery: true # useful for dev/test environment. Default value is 'false'
    default:
        sender: info@example.com
        sender_name: John Doe
        subaccount: Project # Optionally define a subaccount to use
    proxy:
        use: true # when you are behing a proxy. Default value is 'false'
        host: example.com
        port: 80
        user: john
        password: doe123

Now you're all set, send your first transactional mails:

Use

Simple controller Example:

<?php

// src/FFreitasBr/ExampleBundle/Controller/ExampleController.php
namespace FFreitasBr\ExampleBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use FFreitasBr\MandrillBundle\Message;
use FFreitasBr\MandrillBundle\Dispatcher;

class ExampleController extends Controller
{
    public function indexAction()
    {
        $dispatcher = $this->get('mandrill.dispatcher');

        $message = new Message();

        $message
            ->setFromEmail('mail@example.com')
            ->setFromName('Customer Care')
            ->addTo('max.customer@email.com')
            ->setSubject('Some Subject')
            ->setHtml('<html><body><h1>Some Content</h1></body></html>')
            ->setSubaccount('Project');

        $result = $dispatcher->send($message);

        return new Response('<pre>' . print_r($result, true) . '</pre>');

    }

}

统计信息

  • 总下载量: 19
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 49
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-27