jlinn/mandrill-api-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jlinn/mandrill-api-php

最新稳定版本:v1.1.1

Composer 安装命令:

composer require jlinn/mandrill-api-php

包简介

A PHP client library for Mandrill's REST API

关键字:

README 文档

README

Build Status

A PHP client library for Mandrill's API.

This library provides all of the functionality present in the official PHP client, but makes use of namespaces and provides helper classes to ease message sending.

Installation Using Composer

Assuming composer.phar is located in your project's root directory, run the following command:

php composer.phar require jlinn/mandrill-api-php:~1.0

Usage

Sending a Message

use Jlinn\Mandrill\Mandrill;
use Jlinn\Mandrill\Struct\Message;
use Jlinn\Mandrill\Struct\Recipient;

// instantiate a client object
$mandrill = new Mandrill('your_api_key');

// instantiate a Message object
$message = new Message();

// define message properties
$message->text = 'Hello, *|NAME|*!';
$message->subject = 'Test';
$message->from_email = 'test@example.com';
$message->from_name = 'Mandrill API Test';

// instantiate a Recipient object and add details
$recipient = new Recipient();
$recipient->email = 'recipient.email@example.com';
$recipient->name = 'Recipient Name';
$recipient->addMergeVar('NAME', $recipient->name);

// add the recipient to the message
$message->addRecipient($recipient);

// send the message
$response = $mandrill->messages()->send($message);

Usage with Laravel 4.x

We have built a factory so that it's easier to use with Laravel 4.x facades.

Configuration

In order to publish the package configuration you need to perform the following command:

php artisan config:publish jlinn/mandrill-api-php

Change then the secret variable with your Mandrill secret key.

Sending a Message

// instantiate a client object
$api = Mandrill::api();

// instantiate a message object
$message = Mandrill::message([
    'text'       => 'Hello, *|NAME|*!',
    'subject'    => 'Test',
    'from_email' => 'test@example.com',
    'from_name'  => 'Mandrill API Test'
]);

// instantiate a Recipient object and add details
$recipient = Mandrill::recipient('recipient.email@example.com', 'Recipient Name');
$recipient->addMergeVar('NAME', $recipient->name);

// add the recipient to the message
$message->addRecipient($recipient);

// send the message
$response = $api->messages()->send($message);

统计信息

  • 总下载量: 115.03k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 25
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 24
  • Watchers: 4
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-09-16