cristiancy96/mandrill

Mandrill 交易型邮件通过 Laravel 4

dev-master 2013-12-12 16:37 UTC

This package is not auto-updated.

Last update: 2024-09-24 04:40:29 UTC


README

从 Laravel 4 框架发送 Mandrill 交易型邮件。本包是对 doxxon 包的更新,并且是围绕 MichMich 的 Laravel Mandrill Bundle 的 Laravel 4 封装。

安装

  1. 编辑你的项目中的 composer.json 文件,并添加对 doxxon/laravel-mandrill-request 的依赖。

     "require": {
     	"laravel/framework": "4.1.*",
     	"doxxon/laravel-mandrill-request": "dev-master"
     }
    
  2. 从命令行更新 composer

     composer update
    
  3. 打开 app/config/app.php 并将以下行添加到 providers 数组中

     'Doxxon\LaravelMandrillRequest\LaravelMandrillRequestServiceProvider',
    
  4. 添加一个外观别名以启用简短使用。打开 app/config/app.php 并将以下行添加到 aliases 数组中

     'Mandrill' => 'Doxxon\LaravelMandrillRequest\Facades\MandrillRequest',
    
  5. 发布配置文件。这将允许你设置 Mandrill API 密钥

     php artisan config:publish doxxon/laravel-mandrill-request
    
  6. 通过编辑 config/packages/doxxon/laravel-mandrill-request/config.php 来设置你的 Mandrill API 密钥

return array(

	'api_key' => 'your api key here',

);

Mandrill 控制台 获取你的 API 密钥

用法

$payload = array(
	'message' => array(
        'subject' => 'Transactional email via Mandrill',
        'html' => 'It works!',
        'from_email' => 'fromemail@example.com',
        'to' => array(array('email'=>'toemail@example.com'))
   	)
);

$response = Mandrill::request('messages/send', $payload);

查看 Mandrill API 文档获取更多信息