lzaplata / smartemailing
此包最新版本(dev-master)没有可用的许可信息。
Nette 框架的 SmartEmailing 包装器。
dev-master
2018-02-13 08:37 UTC
Requires
- php: >=5.4
- guzzlehttp/guzzle: 5.3.1
- nette/di: ~2.3
- nette/utils: ~2.3
This package is auto-updated.
Last update: 2024-09-25 07:04:57 UTC
README
这是一个 SmartEmailing 的 Nette 框架包装器。
安装
安装库的最简单方法是使用 Composer。
$ composer require lzaplata/smartemailing: dev-master
或者编辑项目中的 composer.json
"require": { "lzaplata/smartemailing": "dev-master" }
您必须在 config.neon 文件中将库注册为扩展。
extensions: smartEmailing: LZaplata\SmartEmailing\DI\Extension
现在您可以设置参数...
smartEmailing: username : * apiKey : *
...并将库自动装配到演示者中
use LZaplata\SmartEmailing\Client; /** @var Client @inject */ public $smartEmailingClient;
使用方法
导入联系人
try { $this->smartEmailingClient->importContact($email, $contactlistId); } catch (\Exception $e) { echo $e->getMessage(); }
获取单个电子邮件
try { $request = $this->smartEmailingClient->getEmail($id); echo $request->json(); } catch (\Exception $e) { echo $e->getMessage(); }
发送自定义电子邮件
首先,您必须声明 LZaplata\SmartEmailing\Helpers\Email 对象,然后将它作为参数传递给 sendCustomEmail 函数。
try { $email = new Email(); $email->setSender($senderEmail, $senderName); $email->setRecipient($recipientEmail, $recipientName); $email->setSubject($subject); $email->setHtmlBody($html); $email->setTag($tag); $email->setReplacements([ "key" => "content" ]); $this->smartEmailingClient->sendCustomEmail($email); } catch (\Exception $e) { echo($e->getMessage()); }