it-can/fuel-mandriller

此包已被废弃且不再维护。没有建议的替代包。

FuelPHP 的 Mandrill 包

dev-master 2016-11-26 10:03 UTC

This package is auto-updated.

Last update: 2022-02-01 12:29:20 UTC


README

======

fuel-mandriller

自行承担风险!API 可能会发生变化!

Build Status Total Downloads

====== Mandrill FuelPHP composer 包 (www.mandrill.com)

安装

通过 Composer

{
    "require": {
        "it-can/fuel-mandriller": "dev-master"
    }
}

接下来您需要发布配置文件

您可以在 fuel/app/config/mandriller.php 中设置您的配置。

<?php

return array(
    // your secret Mandrill API key
    'api_key' => '',

    // enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
    'async' => false,

    // Show receivers of email in cc (if you set this to true, it will show all recipients in the email)
    'preserve_recipients' => false,

    // Set a custom user agent
    'user_agent' => 'Fuel-Mandriller/0.1',

    // Custom headers (for example: array('List-Unsubscribe' => '<mailto:info@example.com>');)
    'custom_headers' => array(),

    // Set your server ip address (optional, only if your server has multiple ip addresses)
    'ip' => '',
);

示例(这仅适用于 send-template 方法,目前只支持 send-template 方法作为 Mandrill 的方法)

<?php

// Send email
try {
    $mandrill = new \Mandriller\Mandriller();
    $mandrill->from('from@example.com', 'From name');
    $mandrill->to('user@example.com');
    $mandrill->reply_to('from@example.com');
    $mandrill->subject('Mandrill template test');
    $mandrill->template('mandrill-test-template');
    $mandrill->mergeVars(array(
        'name' => 'NAME',
        'content' => 'John',
    ));
    $mandrill->important(true); // default = false
    $mandrill->sendTemplate();

    // Do other stuff
} catch (\FuelException $e) {
    echo 'ERROR! ' . $e;
}