maurymmarques/postmark-plugin
Composer 安装命令:
composer require maurymmarques/postmark-plugin
包简介
A CakePHP plugin that makes email delivery using Postmark
README 文档
README
CakePHP plugin that makes email delivery using Postmark
Version
Written for CakePHP 2.x
Copyright
Copyright (c) 2011 Maury M. Marques
Installation
You can install this plugin using Composer, GIT Submodule, GIT Clone or Manually
[Using Composer]
Add the plugin to your project's composer.json - something like this:
{ "require": { "maurymmarques/postmark-plugin": "dev-master" }, "extra": { "installer-paths": { "app/Plugin/Postmark": ["maurymmarques/postmark-plugin"] } } }
Then just run composer install
Because this plugin has the type cakephp-plugin set in it's own composer.json, composer knows to install it inside your /Plugin directory, rather than in the usual vendors file.
[GIT Submodule]
In your app directory (app/Plugin) type:
git submodule add git://github.com/maurymmarques/postmark-cakephp.git Plugin/Postmark git submodule init git submodule update
[GIT Clone]
In your plugin directory (app/Plugin or plugins) type:
git clone https://github.com/maurymmarques/postmark-cakephp.git Postmark
[Manual]
- Download the Postmark archive.
- Unzip that download.
- Rename the resulting folder to
Postmark - Then copy this folder into
app/Plugin/orplugins
Configuration
Bootstrap the plugin in app/Config/bootstrap.php:
CakePlugin::load('Postmark');
Create the file app/Config/email.php with the class EmailConfig.
class EmailConfig { public $postmark = array( 'transport' => 'Postmark.Postmark', 'uri' => 'http://api.postmarkapp.com/email', 'key' => 'your-postmark-key', 'track_opens' => true ); }
If you want your connection to Postmark to be encrypted, simply change the uri to use https.
You can set track_opens to false or remove it from the config array if you don't want Postmark to track emails.
Read more about Open Tracking.
Note: Make sure to modified the API key to match the credentials for your Postmark server rack instance.
Proxy
You can also configure a proxy in the file app/Config/email.php:
class EmailConfig { public $postmark = array( 'transport' => 'Postmark.Postmark', 'uri' => 'http://api.postmarkapp.com/email', 'key' => 'your-postmark-key', 'track_opens' => true, 'proxy' => array( 'host' => 'your-proxy-host', # Can be an array with settings to authentication class 'port' => 3128, # Default 3128 'method' => null, # Proxy method (ie, Basic, Digest). If empty, disable proxy authentication 'user' => null, # Username if your proxy need authentication 'pass' => null # Password to proxy authentication ), ); }
Read more about HttpSocket Parameters.
Usage
This plugin uses CakeEmail, and works virtually the same.
Then, simply send messages like this:
App::uses('CakeEmail', 'Network/Email'); $email = new CakeEmail(); $email->config('postmark'); $email->from('yourpostmark@mail.com'); $email->to('recipient@domain.com'); $email->subject('Test Postmark'); $email->send('Message');
Or use more resources:
App::uses('CakeEmail', 'Network/Email'); $email = new CakeEmail(); $email->config('postmark'); $email->template('default', 'default'); $email->emailFormat('html'); $email->viewVars(array('name' => 'Your Name')); $email->from(array('yourpostmark@mail.com' => 'Your Name')); $email->to(array('recipient1@domain.com' => 'Recipient1', 'recipient2@domain.com' => 'Recipient2')); $email->cc(array('recipient3@domain.com' => 'Recipient3', 'recipient4@domain.com' => 'Recipient4')); $email->bcc(array('recipient5@domain.com' => 'Recipient5', 'recipient6@domain.com' => 'Recipient6')); $email->subject('Test Postmark'); $email->addHeaders(array('Tag' => 'my tag')); $email->attachments(array( 'cake.icon.png' => array( 'file' => WWW_ROOT . 'img' . DS . 'cake.icon.png' ) )); $email->send();
If you need the instance of the class PostmarkTrasport:
App::uses('CakeEmail', 'Network/Email'); $email = new CakeEmail(); $postmarkInstance = $email->transport('Postmark.Postmark')->transportClass();
The syntax of all parameters is the same as the default CakeEmail:
http://book.cakephp.org/2.0/en/core-utility-libraries/email.html
For more information, see the Postmark API documentation:
http://developer.postmarkapp.com/#message-format
Debugging
You can see the response from Postmark in the return value when you send a message:
$result = $email->send('Message'); $this->log($result, 'debug');
If there are any errors, they'll be included in the response. See the Postmark API documentation for error code detail:
http://developer.postmarkapp.com/#api-error-codes
CakePHP 1.3+
This class does not work for CakePHP 1.3, for this see:
maurymmarques/postmark-plugin 适用场景与选型建议
maurymmarques/postmark-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.69k 次下载、GitHub Stars 达 20, 最近一次更新时间为 2015 年 02 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「cakephp」 「postmark」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 maurymmarques/postmark-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 maurymmarques/postmark-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 maurymmarques/postmark-plugin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
PHP Library to send email across all platforms using one interface.
Provides an email provider for postmarkapp.com
A minor update of Miguel Perez's no-longer maintained code from https://github.com/miguel250/PostmarkBundle to allow for Symfony 3 compatibility. All credit/kudos/thanks for the work should obviously go to him
Email Toolkit Plugin for CakePHP
Verify, normalize, and track email delivery webhooks from SendGrid, Postmark, Mailgun, Amazon SES, and Resend
统计信息
- 总下载量: 11.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-08