Browse Source

init

tags/1.0
0nepeop1e 4 years ago
commit
1adbc5afbe
4 changed files with 136 additions and 0 deletions
  1. 3
    0
      .gitignore
  2. 51
    0
      README.md
  3. 36
    0
      composer.json
  4. 46
    0
      src/MirfalahSendmailServiceProvider.php

+ 3
- 0
.gitignore View File

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

+ 51
- 0
README.md View File

@@ -0,0 +1,51 @@
1
+#mirfalah/laravel-swift
2
+
3
+Service provider for laravel which provide Mirfalah Swift_Transport implementation
4
+
5
+---
6
+##Installation
7
+
8
+Add following repository records into `composer.json`
9
+```json
10
+{
11
+  "repositories": [
12
+    {
13
+      "type": "vcs",
14
+      "url": "https://git.mirfalah.my/mirfalah-tech/sendmail-swift-transport.git"
15
+    },
16
+    {
17
+      "type": "vcs",
18
+      "url": "https://git.mirfalah.my/mirfalah-tech/laravel-swift.git"
19
+    }
20
+  ]
21
+}
22
+```
23
+Then execute
24
+```shell script
25
+composer require mirfalah/laravel-swift ^1.0
26
+```
27
+
28
+---
29
+##Usage
30
+
31
+```php
32
+# file: config/mail.php
33
+return [
34
+    ...
35
+    'mirfalah' => [
36
+        'api_key'=> env('MIRFALAH_SENDMAIL_APIKEY'),
37
+        'secret'=> env('MIRFALAH_SENDMAIL_SECRET'),
38
+        'endpoint' => env(
39
+            'MIRFALAH_SENDMAIL_ENDPOINT',
40
+            'https://pahangmail.mirfalah.my/mirfalah-sendmail/index.php'
41
+        )
42
+    ]
43
+    ...
44
+];
45
+```
46
+```dotenv
47
+# file: .env
48
+MAIL_DRIVER=mirfalah
49
+MIRFALAH_SENDMAIL_APIKEY=""
50
+MIRFALAH_SENDMAIL_SECRET=""
51
+```

+ 36
- 0
composer.json View File

@@ -0,0 +1,36 @@
1
+{
2
+    "name": "mirfalah/laravel-swift",
3
+    "description": "Service provider for laravel which provide Mirfalah Swift_Transport implementation",
4
+    "type": "library",
5
+    "require": {
6
+        "php": ">=7.2",
7
+        "illuminate/mail": ">=5 <7",
8
+        "illuminate/support": ">=5 <7",
9
+        "mirfalah/sendmail-swift-transport": "^1.0"
10
+    },
11
+    "license": "Mirfalah-Tech",
12
+    "authors": [
13
+        {
14
+            "name": "Eng Shun",
15
+            "email": "engshun@mirfalah.my"
16
+        }
17
+    ],
18
+    "autoload": {
19
+        "psr-4": {
20
+            "MirfalahTech\\Laravel\\Mail\\": "src/"
21
+        }
22
+    },
23
+    "repositories": [
24
+        {
25
+            "type": "vcs",
26
+            "url": "https://git.mirfalah.my/mirfalah-tech/sendmail-swift-transport.git"
27
+        }
28
+    ],
29
+    "extra": {
30
+        "laravel": {
31
+            "providers": [
32
+                "MirfalahTech\\Laravel\\Mail\\MirfalahSendmailServiceProvider"
33
+            ]
34
+        }
35
+    }
36
+}

+ 46
- 0
src/MirfalahSendmailServiceProvider.php View File

@@ -0,0 +1,46 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Mail;
5
+
6
+
7
+use Illuminate\Contracts\Config\Repository;
8
+use Illuminate\Contracts\Container\BindingResolutionException;
9
+use Illuminate\Contracts\Container\Container;
10
+use Illuminate\Mail\TransportManager;
11
+use Illuminate\Support\AggregateServiceProvider;
12
+use MirfalahTech\Swift\MirfalahTransport;
13
+
14
+class MirfalahSendmailServiceProvider extends AggregateServiceProvider
15
+{
16
+    /**
17
+     * @throws BindingResolutionException
18
+     */
19
+    public function boot()
20
+    {
21
+        /** @var Repository $config */
22
+        $config = $this->app->make('config');
23
+
24
+        $config->set([
25
+            'mail.mirfalah' => array_merge([
26
+                'api_key' => env('MIRFALAH_SENDMAIL_APIKEY'),
27
+                'secret' => env('MIRFALAH_SENDMAIL_SECRET'),
28
+                'endpoint' => env(
29
+                    'MIRFALAH_SENDMAIL_ENDPOINT',
30
+                    'https://pahangmail.mirfalah.my/mirfalah-sendmail/index.php'
31
+                ),
32
+            ], $config->get('mail.mirfalah', []))
33
+        ]);
34
+
35
+        $this->app->afterResolving('swift.transport',
36
+            function (TransportManager $manager) use ($config) {
37
+                $manager->extend('mirfalah', function (Container $app) use ($config) {
38
+                    return new MirfalahTransport(
39
+                        $config->get('mail.mirfalah.api_key', env('MIRFALAH_SENDMAIL_APIKEY')),
40
+                        $config->get('mail.mirfalah.secret', env('MIRFALAH_SENDMAIL_SECRET')),
41
+                        $config->get('mail.mirfalah.endpoint', env('MIRFALAH_SENDMAIL_ENDPOINT'))
42
+                    );
43
+                });
44
+            });
45
+    }
46
+}

Loading…
Cancel
Save