You've already forked laravel-mail
Initialization
This commit is contained in:
42
BMailApi.php
Normal file
42
BMailApi.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace BMail;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
|
||||
class BMailApi
|
||||
{
|
||||
/**
|
||||
* The API key
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $api_key;
|
||||
|
||||
public function __construct(string $api_key)
|
||||
{
|
||||
$this->api_key = $api_key;
|
||||
}
|
||||
|
||||
public function send($template)
|
||||
{
|
||||
$url = "http://127.0.0.1:9000/api/project/template/send";
|
||||
|
||||
// TODO
|
||||
// $url = "http://127.0.0.1:9000/api/project/template/send";
|
||||
|
||||
$client = new Client();
|
||||
|
||||
try {
|
||||
return $client->request('post', $url, [
|
||||
'form_params' => $template,
|
||||
'headers' => ['Authorization' => 'Bearer ' . $this->api_key]
|
||||
])->getBody();
|
||||
|
||||
} catch(\Exception $e) {
|
||||
throw new BMailException($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user