awsm3 / mandrill-zend3
Zend Framework 3 的 Mandrill REST API 的 PHP 客户端库
3.0
2018-03-31 22:19 UTC
Requires
- php: >=7.0
- zendframework/zend-http: ~2.7
- zendframework/zend-json: ~3.0
- zendframework/zend-mail: ~2.7
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2024-09-20 02:06:22 UTC
README
PHP ZF3 客户端库,用于 Mandrill API。
该库提供了官方 PHP 客户端中的所有功能,但使用命名空间,提供辅助类以简化消息发送,并与 Zend Framework 3(使用其库)一起工作。
该库基于 Joe Linn 的库(https://github.com/jlinn/mandrill-api-php)。
使用 Composer 安装
假设 composer.phar 位于您的项目根目录中,请运行以下命令
composer require awsm3/mandrill-zend3
用法
发送消息
/** @uses */ use Mandrill\Mandrill; use Mandrill\Struct\Message; use 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);
发送 ZF3 消息
/** @uses */ use Mandrill\Mandrill; use Mandrill\Struct\Message; // convert from ZF message // $zfMessage is instance of \Zend\Mail\Message $message = Message::convertZFMail($zfMessage); // add any field you want $message->metadata = ...; // instantiate a client object $mandrill = new Mandrill('your_api_key'); // send the message $response = $mandrill->messages()->send($message);