雪帽 / mailjet-bundle
用于Symfony2的Mailjet包装器
dev-master
2014-09-04 17:00 UTC
Requires
- php: >=5.3.2
- symfony/framework-bundle: >=2.3
This package is not auto-updated.
Last update: 2024-09-14 14:34:46 UTC
README
雪帽Mailjet Bundle是雪帽用来帮助处理Mailjet API的一个bundle。
它包括了一个重构版的Mailjet API客户端(可在https://www.mailjet.com/plugin/php-mailjet.class.php找到)并满足
- PSR-0标准
- 新常量
- bundle配置
先决条件
这个bundle版本需要Symfony 2.1+。
安装
使用composer下载SnowcapMailjetBundle
在您的composer.json中添加SnowcapCoreBundle
{ "require": { "snowcap/mailjet-bundle": "*" } }
现在运行以下命令让composer下载bundle
$ php composer.phar update snowcap/mailjet-bundle
composer会将bundle安装到您项目的vendor/snowcap
目录下。
启用Bundle
在kernel中启用bundle
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Snowcap\MailjetBundle\SnowcapMailjetBundle(), ); }
配置Mailjet
在您的config.yml中
snowcap_mailjet: api_key: %mailjet_api_key% secret_key: %mailjet_secret_key%
有一个可选参数"debug"可用(默认为0)。更多详情请参考Mailjet文档。
使用方法
API通过"snowcap_mailjet"服务提供。在您的控制器(或其他地方)
public function newsletterAction() { // Get Mailjet client $client = $this->get('snowcap_mailjet'); // Add an email to a mailing list $client->listsAddcontact( array( 'contact' => 'someone@email.com', 'id' => 'your-list-id', 'force' => true, 'method' => 'POST' ) ); }