0nepeop1e преди 4 години
ревизия
8f6d9bc396
променени са 3 файла, в които са добавени 116 реда и са изтрити 0 реда
  1. 3
    0
      .gitignore
  2. 21
    0
      composer.json
  3. 92
    0
      src/MirfalahTransport.php

+ 3
- 0
.gitignore Целия файл

@@ -0,0 +1,3 @@
1
+.idea/
2
+vendor/
3
+composer.lock

+ 21
- 0
composer.json Целия файл

@@ -0,0 +1,21 @@
1
+{
2
+    "name": "mirfalah/sendmail-swift-transport",
3
+    "description": "Mirfalah Sendmail Swift_Transport implementation",
4
+    "type": "library",
5
+    "require": {
6
+        "swiftmailer/swiftmailer": "^6.0",
7
+        "guzzlehttp/guzzle": "~6.0"
8
+    },
9
+    "license": "Mirfalah-Tech",
10
+    "authors": [
11
+        {
12
+            "name": "Eng Shun",
13
+            "email": "engshun@mirfalah.my"
14
+        }
15
+    ],
16
+    "autoload": {
17
+        "psr-4": {
18
+            "MirfalahTech\\Swift\\": "src/"
19
+        }
20
+    }
21
+}

+ 92
- 0
src/MirfalahTransport.php Целия файл

@@ -0,0 +1,92 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Swift;
5
+
6
+
7
+use GuzzleHttp\Client;
8
+use GuzzleHttp\RequestOptions;
9
+use Swift_Events_EventListener;
10
+use Swift_Mime_SimpleMessage;
11
+use Swift_Transport;
12
+
13
+class MirfalahTransport implements Swift_Transport
14
+{
15
+    /**
16
+     * @var string
17
+     */
18
+    protected $apiKey;
19
+
20
+    /**
21
+     * @var string
22
+     */
23
+    protected $secret;
24
+
25
+    /**
26
+     * @var string
27
+     */
28
+    protected $endpoint;
29
+
30
+    /**
31
+     * @var Client
32
+     */
33
+    protected $client;
34
+
35
+    public function __construct($apiKey, $secret, $endpoint)
36
+    {
37
+        $this->apiKey = $apiKey;
38
+        $this->secret = $secret;
39
+        $this->endpoint = $endpoint;
40
+        $this->client = new Client();
41
+    }
42
+
43
+    /**
44
+     * @inheritDoc
45
+     */
46
+    public function isStarted()
47
+    {
48
+    }
49
+
50
+    /**
51
+     * @inheritDoc
52
+     */
53
+    public function start()
54
+    {
55
+    }
56
+
57
+    /**
58
+     * @inheritDoc
59
+     */
60
+    public function stop()
61
+    {
62
+    }
63
+
64
+    /**
65
+     * @inheritDoc
66
+     */
67
+    public function ping()
68
+    {
69
+    }
70
+
71
+    /**
72
+     * @inheritDoc
73
+     */
74
+    public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
75
+    {
76
+        $body = (string) $message;
77
+        $this->client->post($this->endpoint, [
78
+            RequestOptions::QUERY => [
79
+                'apiKey' => $this->apiKey,
80
+                'signature' => hash_hmac('sha1', $body, $this->secret),
81
+            ],
82
+            RequestOptions::BODY => $body,
83
+        ]);
84
+    }
85
+
86
+    /**
87
+     * @inheritDoc
88
+     */
89
+    public function registerPlugin(Swift_Events_EventListener $plugin)
90
+    {
91
+    }
92
+}

Loading…
Отказ
Запис